Question: Java I really need help PLEASE. I am stuck and can not figure this out. I am new and appreciate anything from pseudo code to

Java

I really need help PLEASE. I am stuck and can not figure this out. I am new and appreciate anything from pseudo code to actual code to help. I just need to see whats going on. I dont want to copy I want to understand! Thanks so much!

1. HouseType (25%) A mutable ADT that represents a house. The house instance should have the following properties: String address, integer id, double price, int array that represents the size of each room in the house (a house may have up to 10 rooms). Add a class level field that counts the number of house objects. The house id should be set up in the following way: house id = its object number, i.e. the first house created by client code should have id 1, the second house created by client code should have id 2, the third house created by client code should have id 3, etc. Add the following methods to your ADT, implementing the following class invariant: room size > 0, price >= 0, and make sure your code does not violate encapsulation principles: parameterless and parameterized constructors (parameters: address, price, array with room sizes) copy constructor that creates a deep copy of an object get methods for all the fields set methods for address and price toString method setRoomSize method that takes the number representing the room (e.g. room number 3) and the size of the room in square feet and resets that particular room size to the new value calculateSize method that adds up and returns the size of the entire house calculatePricePerFoot method that calculates and returns the price per square foot, e.g. if a house is 300K and it is 1200 square feet, then the method should return 250. Test your class in a driver. 2. Composition (25%) Copy your HouseType class and give it a new name HouseTypeMoney. Replace the price field data type from double to MoneyType and make appropriate modification to the methods that use the price. Make sure your MoneyType class is in the same folder. Test your class in a driver. 3. Immutability (25%) Copy your HouseTypeMoney class and give it a new name HouseTypeMoneyImmutable and make it immutable. In order to do so: remember to use the final keyword were appropriate update all the set methods so that they return a new object update all the get methods that return a modifiable field so that they return a deep copy of a modifiable field rather than the field itself update all methods that take modifiable types as parameters so that they do NOT use them directly but rather create deep copies of these parameters Test your class in a driver. 4. Arrays of Objects and Composition (25%) Download the class GroceryItemOrder.java from Canvas. This class represents a request to purchase a particular - 2 - item in a given quantity (example: four boxes of cookies). Then, create a class named GroceryList that represents a list of items to buy from the market, i.e. a list of GroceryItemOrder objects. You should model this class after MyIntList.java we created in class, except instead of an array of ints, your class will contain an array of GroceryItemOrder objects. Your GroceryList class should contain the following methods: Constructors: - a parameterless constructor that constructs a new empty grocery list - a copy constructor that creates a deep copy of the list (remember that a deep copy means that the array and the objects need to be copied in a similar manner as in the lecture example involving Points) The following methods: - public void add(GroceryItemOrder item): Adds the given item order to this list. - public double getTotalCost(): Returns the total sum cost of all grocery item orders in this list. - public String toString method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!