Advertisement
Dakpluto

Garage.java

Nov 30th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. public class Garage extends Building {
  2.     private int cars;
  3.     private GarageFlooring flooring;
  4.     private int length;
  5.     private int width;
  6.  
  7.     public enum GarageFlooring {
  8.         CEMENT, GRAVEL
  9.     }
  10.  
  11.     public Garage(int windows, int cars, GarageFlooring flooring, int length,
  12.             int width) {
  13.         super(windows);
  14.         this.cars = cars;
  15.         this.flooring = flooring;
  16.         this.length = length;
  17.         this.width = width;
  18.     }
  19.  
  20.     public int getCars() {
  21.         return cars;
  22.     }
  23.  
  24.     public void setCars(int cars) {
  25.         this.cars = cars;
  26.     }
  27.  
  28.     public int getLength() {
  29.         return length;
  30.     }
  31.  
  32.     public void setLength(int length) {
  33.         this.length = length;
  34.     }
  35.  
  36.     public int getWidth() {
  37.         return width;
  38.     }
  39.  
  40.     public void setWidth(int width) {
  41.         this.width = width;
  42.     }
  43.  
  44.     public int area() {
  45.         int result;
  46.         result = this.length * this.width;
  47.  
  48.         return result;
  49.     }
  50.  
  51.     @Override
  52.     public String toString() {
  53.         String result;
  54.  
  55.         result = "-Garage-\nCars: " + cars + "\nLength: " + length
  56.                 + "' - Width: " + width + "' - Area: " + area()
  57.                 + "'\nFlooring: " + flooring;
  58.  
  59.         return result;
  60.     }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement