Advertisement
Guest User

Main.java

a guest
Oct 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static flat_geometric_shape figure1 = new flat_geometric_shape();
  7.     public static flat_geometric_shape figure2;
  8.     public static String nameFigure;
  9.     //public static Square Sq;
  10.     //public static Rectangle Rect;
  11.     public static boolean t = true;
  12.  
  13.     public static void main(String[] args)
  14.     {
  15.     // write your code here
  16.         /*figure1.setNameFigure("Figure1");
  17.         System.out.println("Объект" + figure1.getNameFigure() + "\nПлощадь = " + figure1.getS() + "\nПериметр = " + figure1.getP());
  18.  
  19.         try
  20.         {
  21.             figure1.setNameFigure("");
  22.         }
  23.         catch (IllegalArgumentException e)
  24.         {
  25.             System.out.println(e);
  26.         } */
  27.  
  28.         String s;
  29.         while(t)
  30.         {
  31.             Processing_Base_class();
  32.             if(figure2 != null)
  33.             {
  34.                 switch(s = figure2.getNameFigure())
  35.                 {
  36.                     case "Square":
  37.                         //Processing_Square_class();
  38.                         break;
  39.                     case "Rectangle":
  40.                         //Processing_Rectangle_class();
  41.                         break;
  42.                     case "Quit":
  43.                         t = false;
  44.                         break;
  45.                 }
  46.             }
  47.             else System.out.println("Объект не создан");
  48.  
  49.         }
  50.     }
  51.  
  52.     public static void Processing_Base_class()
  53.     {
  54.         System.out.println("Введите название фигуры : Square или Rectangle или Quit");
  55.         Scanner newin = new Scanner(System.in);
  56.         nameFigure = new String(newin.nextLine());
  57.         try {
  58.             figure2 = new flat_geometric_shape(nameFigure);
  59.         }
  60.         catch(IllegalArgumentException e) {
  61.             System.out.println(e);
  62.         }
  63.     }
  64.  
  65.     public static void Processing_Square_class()
  66.     {
  67.         System.out.println("Введите длину стороны квадрата");
  68.         Scanner newin = new Scanner(System.in);
  69.         double length = newin.nextDouble();
  70.         try {
  71.             Square Sq = new Square(length, nameFigure);
  72.             Sq.P();
  73.             Sq.S();
  74.             System.out.println(Sq.getNameFigure() + "\nПлощадь = " + Sq.getS() + "\nПериметр = " + Sq.getP());
  75.         }
  76.         catch(IllegalArgumentException e) {
  77.             System.out.println(e);
  78.         }
  79.     }
  80. }
  81.  
  82. //https://pastebin.com/4QKRQvHL
  83. //https://pastebin.com/S8Vg1imN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement