Java Project Building an array in array -


hey guys need java project working on.

basically have 5 classes testclass, building, house, garage, , houserooms

  • a building has number of floors, , number of windows.
  • a house building.

  • a garage building.

  • a room has length, width, floor covering, , number of closets.

  • a house has number of bathrooms, , array of rooms.
  • a house has method returns average size of rooms.
  • a garage can hold number of cars, , may have cement floor or gravel floor.

  • a garage has length , width. (don’t use room class member of garage class.)

the testclass must have arraylist have, unsure of how create array of rooms each house own objects. i've tried can see in houserooms class don't know if thats best way go about.

image

public class testclass {     public static void main(string[] args) {         arraylist<building> buildings = new arraylist();     } }  public class building {     private string buildingtype; //house or garage     private int floors;     private int windows; }  public class house extends building {     private int bathrooms;     private arraylist<room> rooms = new arraylist(); } class rooms {        private double length;     private double width;     private string floorcover;      private int closets; }  public class garage extends building {     private int cars;     private string floortype;     private double length;     private double width; } 

you can use enum type buildingtype variable

 public class building {         private buildingtype buildingtype; //house or garage         private int floors;         private int windows;      enum buildingtype{     house,garage     }      } 

and room class shouldn't extend house instead of house should have rooms as:

public class house extends building {     private int bathrooms;     private arraylist<room> rooms = new arraylist(); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -