Advertisement
Guest User

Square.java

a guest
Oct 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package com.company;
  2.  
  3. /**
  4.  * Created by admin on 23.10.2018.
  5.  */
  6. public class Square extends flat_geometric_shape {
  7.     protected double length;
  8.  
  9.     public Square(double len, String nameFigure) throws IllegalArgumentException
  10.     {
  11.         super(nameFigure);
  12.         if(len <= 0)
  13.             throw new IllegalArgumentException("Длина стороны квадрата <= 0");
  14.         this.length = len;
  15.     }
  16.  
  17.     @Override
  18.     public void S()
  19.     {
  20.         S = length*length;
  21.     }
  22.  
  23.     @Override
  24.     public void P()
  25.     {
  26.         P = 4*length;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement