tx
public static void main(String[] args) {
//pass in the cmd args as parameters for the Picture class
aPicture = new Picture(Integer.parseInt(args[0]), Integer.parseInt(args[0]));
Scanner kbEntry = new Scanner(System.in);
// Menu();
String input = kbEntry.next();
char menuOptions = input.charAt(0);
do {
System.out.println("'S' - To add a Square ");
System.out.println("'L' - To add a Line");
System.out.println("'U' - To remove last added item");
System.out.println("'D' - To load a drawing from a file ");
System.out.println("'V' - To save a drawing to a file ");
System.out.println("'N' - New Picture ");
System.out.println("'Q' - Quit:\n");
switch (menuOptions) {
case 'S':
// Picture aPicture;
System.out.println("Enter the value of x: ");
int x = kbEntry.nextInt();
System.out.println("Enter the value of y: ");
int y = kbEntry.nextInt();
System.out.println("Enter the value of z: ");
int z = kbEntry.nextInt();
// Picture.class.getMethod(addSquare(x,y,z),keyboardEntry.nextInt());
aPicture.addSquare(x, y, z);
break;
case 'L':
System.out.println("Enter the value of x1: ");
int x1 = kbEntry.nextInt();
System.out.println("Enter the value of y1: ");
int y1 = kbEntry.nextInt();
System.out.println("Enter the value of x2: ");
int x2 = kbEntry.nextInt();
System.out.println("Enter the value of y2: ");
int y2 = kbEntry.nextInt();
aPicture.addLine(x1, y1, x2, y2);
break;
case 'U':
aPicture.undo();
break;
case 'D':
System.out.println("Enter the Filename: ");
try {
aPicture.load(kbEntry.next());
} catch (Exception e) {
System.out.println("This file does not exist !!!");
}
break;
case 'V':
System.out.println("Enter the Filename: ");
aPicture.save(kbEntry.next());
break;
case 'N':
aPicture = new Picture(Integer.parseInt(args[0]), Integer.parseInt(args[0]));
break;
case 'Q':
break;
default: System.out.println("You Entered wrong menuOption");
}
} while (menuOptions != 'Q');
}

New Topic/Question
Reply




MultiQuote








|