68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #66328 in Java | JSP | JSF for freddy

Question #66328
Write a new public method in your Beach class called addTurtle(). This method should pick a random x/y location (e.g., using Random.generator()) on the beach and add a single Turtle there.

How do I do this??
Expert's answer
import java.io.*;
import java.util.Random;
import java.util.Vector;

public class Main
public static void main(String[] args) throws IOException
//BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));

Beach beach = new Beach();



class Turtle
private int mX;
private int mY;
public Turtle(int x, int y)
mX = x;
mY = y;

public int x()
return mX;
public int y()
return mY;

class Beach
private Vector<Turtle> mVectorTurtle;

public Beach()
mVectorTurtle = new Vector<Turtle>();
public void addTurte()
Random rand = new Random();
Turtle turtle = new Turtle(rand.nextInt(), rand.nextInt());

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions