Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CircleTest
- {
- public static void main(String args[])
- {
- Scanner scan = new Scanner(System.in);
- boolean exit = false;
- int menu, command;
- double rad;
- Circle circ = new Circle();
- String col = new String();
- System.out.print("Choose your circle:\n");
- System.out.print("1. Default\n");
- System.out.print("2. Custom radius\n");
- System.out.print("3. Custom radius and color\n");
- menu = scan.nextInt();
- switch(menu)
- {
- case 1:
- Circle circle = new Circle();
- System.out.print("Circle created!\n");
- System.out.print("Your circle:\n");
- System.out.print("Radius: "+ circle.getRadius() + "\n");
- System.out.println("Color: "+circle.getColor());
- circ = circle;
- break;
- case 2:
- System.out.print("Enter your radius: ");
- rad = scan.nextDouble();
- Circle circle2 = new Circle(rad);
- System.out.print("Circle created!\n");
- System.out.print("Your circle:\n");
- System.out.print("Radius: "+ circle2.getRadius() + "\n");
- System.out.println("Color: "+circle2.getColor());
- circ = circle2;
- break;
- case 3:
- System.out.print("Enter your color: ");
- col = scan.nextLine();
- System.out.print("Enter your radius: ");
- rad = scan.nextDouble();
- Circle circle3 = new Circle(rad, col);
- System.out.print("Circle created!\n");
- System.out.print("Your circle:\n");
- System.out.print("Radius: "+ circle3.getRadius() + "\n");
- System.out.println("Color: "+circle3.getColor());
- circ = circle3;
- break;
- }
- while(!exit)
- {
- System.out.print("Choose your command:\n");
- System.out.print("1. Show circle area.\n");
- System.out.print("2. Change radius.\n");
- System.out.print("3. Change color.\n");
- System.out.println("4. Exit.");
- command = scan.nextInt();
- switch(command)
- {
- case 1:
- System.out.println("Area : " + circ.getArea());
- break;
- case 2:
- System.out.print("New radius : ");
- rad = scan.nextDouble();
- circ.setRadius(rad);
- System.out.print("Your circle:\n");
- System.out.print("Radius: "+ circ.getRadius() + "\n");
- System.out.println("Color: "+circ.getColor());
- break;
- case 3:
- System.out.print("New color : ");
- col = scan.nextLine();
- circ.setColor(col);
- System.out.print("Your circle:\n");
- System.out.print("Radius: "+ circ.getRadius() + "\n");
- System.out.println("Color: "+circ.getColor());
- break;
- case 4:
- exit = true;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement