Beispiel #1
0
  public static void main(String[] args) {

    // Part 1
    Turtle t1, t2, t3;

    t1 = new Turtle();
    t2 = new Turtle("Larry");
    t3 = new Turtle("kevin", 100, 500);

    System.out.println("Turtle 1 is called" + " " + t1.getname());
    System.out.println("Turtle 1 is" + " " + t1.getage() + " " + "years old");
    System.out.println("Turtle 1 is going at" + " " + t1.getspeed() + " " + "mph");

    System.out.println("Turtle 2 is called" + " " + t2.getname());
    System.out.println("Turtle 2 is" + " " + t2.getage() + " " + "years old");
    System.out.println("Turtle 2 is going at" + " " + t2.getspeed() + " " + "mph");

    System.out.println("--------------------------");

    // Part 2
    Person p1;

    p1 = new Person("Vincent");

    p1.setTurtle(t1);

    System.out.println(p1.getPersonName() + "'s turtle's speed is" + " " + p1.getTurtleSpeed());
    System.out.println(p1.getPersonName() + "'s turtle's name is" + " " + p1.getPet());
  }
 public static void main(String[] args) {
   PrintStream outAlias = System.out;
   Turtle tommy = new Turtle("Tommy", new Formatter(System.out));
   Turtle terry = new Turtle("Terry", new Formatter(outAlias));
   tommy.move(0, 0);
   terry.move(4, 8);
   tommy.move(3, 4);
   terry.move(2, 5);
   tommy.move(3, 3);
   terry.move(3, 3);
 }
Beispiel #3
0
 // write method to return turtle's speed
 public int getTurtleSpeed() {
   return turtle.getSpeed();
 }