Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class gironx_BugSimulation {
- public static void main(String [] args) {
- gironx_Bug bug = new gironx_Bug();
- Scanner input = new Scanner(System.in);
- System.out.println("Enter an initial position.");
- String dir = "right";
- bug.setDirection(dir);
- int pos = input.nextInt();
- bug.setPosition(pos);
- System.out.println("The bug has been created facing right at the position: " + pos);
- System.out.println("How many moves do you wish to make?");
- int NumMov = input.nextInt();
- for(int iteration = 0; iteration < NumMov; iteration++) {
- System.out.println("The bug has moved");
- pos = bug.Move();
- }
- System.out.println("The new position for the bug is: " + pos + " It is facing " + dir);
- System.out.println("How many time do you wish to turn?");
- int TurMov = input.nextInt();
- for(int iteration = 0; iteration < TurMov; iteration++) {
- dir = bug.Turn();
- System.out.println("The bug has turned");
- }
- System.out.println("The new direction the bug is facing is: " + dir + " and its position is: " + pos);
- System.out.println("How many time do you wish to move? ");
- int NewMov = input.nextInt();
- for(int iteration = 0; iteration < NewMov; iteration++) {
- pos = bug.Move();
- System.out.println("The bug has moved.");
- }
- System.out.println("The bug's final position is " + pos + " and the direction it is facing is: " + dir);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement