Advertisement
FaisalJamil

Homework 2.6

Feb 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. //MileMover class
  2. import becker.robots.*;
  3. public class MileMover extends Robot {
  4.     int i;
  5.     int j;
  6.     public MileMover(City city, int aStreet, int anAvenue, Direction aDirection) {
  7.         super(city, aStreet, anAvenue, aDirection);
  8.     }
  9.     public void moveMile() {
  10.         for (i=1;i<=10;i++) {
  11.             this.move();
  12.         }
  13.     }
  14.     public void move1000Miles() {
  15.         for (j=1;j<=1000;j++) {
  16.             this.moveMile();
  17.         }
  18.     }
  19. }
  20.  
  21. //Main class
  22. import becker.robots.*;
  23. public class Main {
  24.  
  25.     public static void main(String[] args) {
  26.         City Mississauga = new City();
  27.         MileMover Robot = new MileMover(Mississauga,0,0,Direction.EAST);
  28.         Robot.move1000Miles();
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement