Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static flat_geometric_shape figure1 = new flat_geometric_shape();
- public static flat_geometric_shape figure2;
- public static String nameFigure;
- //public static Square Sq;
- //public static Rectangle Rect;
- public static boolean t = true;
- public static void main(String[] args)
- {
- // write your code here
- /*figure1.setNameFigure("Figure1");
- System.out.println("Объект" + figure1.getNameFigure() + "\nПлощадь = " + figure1.getS() + "\nПериметр = " + figure1.getP());
- try
- {
- figure1.setNameFigure("");
- }
- catch (IllegalArgumentException e)
- {
- System.out.println(e);
- } */
- String s;
- while(t)
- {
- Processing_Base_class();
- if(figure2 != null)
- {
- switch(s = figure2.getNameFigure())
- {
- case "Square":
- //Processing_Square_class();
- break;
- case "Rectangle":
- //Processing_Rectangle_class();
- break;
- case "Quit":
- t = false;
- break;
- }
- }
- else System.out.println("Объект не создан");
- }
- }
- public static void Processing_Base_class()
- {
- System.out.println("Введите название фигуры : Square или Rectangle или Quit");
- Scanner newin = new Scanner(System.in);
- nameFigure = new String(newin.nextLine());
- try {
- figure2 = new flat_geometric_shape(nameFigure);
- }
- catch(IllegalArgumentException e) {
- System.out.println(e);
- }
- }
- public static void Processing_Square_class()
- {
- System.out.println("Введите длину стороны квадрата");
- Scanner newin = new Scanner(System.in);
- double length = newin.nextDouble();
- try {
- Square Sq = new Square(length, nameFigure);
- Sq.P();
- Sq.S();
- System.out.println(Sq.getNameFigure() + "\nПлощадь = " + Sq.getS() + "\nПериметр = " + Sq.getP());
- }
- catch(IllegalArgumentException e) {
- System.out.println(e);
- }
- }
- }
- //https://pastebin.com/4QKRQvHL
- //https://pastebin.com/S8Vg1imN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement