This file defines aHouse object. Variables: All variables must not be allowed to be directly modified outside the class in which they are declared, unless otherwise stated in the description of the...

This file defines aHouse object. Variables: All variables must not be allowed to be directly modified outside the class in which they are declared, unless otherwise stated in the description of the variable. The House class must have these variables: • address- the address of the House, which can be made of any combination of characters • yearBuilt-the year the House was built as an integer(note: this value cannot be negative) • numBaths– the number of bathrooms of the House as a double (note: only nonnegative values divisible by 0.5 are allowed here) • isRenovated - the renovation status of the House as a boolean Constructor(s): • A constructor that takes in the address, yearBuilt,numBaths, andisRenovated. • A constructor that takes in the addressandnumBaths. In this case, yearBuiltshould be assumed to be 1984 and isRenovatedshould be assumed to be false. • A constructor that takes in no arguments. In this case, yearBuiltshould be assumed to be 1984, isRenovatedshould be assumed to be false, addressshould be assumed to be “North Ave NW, Atlanta, GA 30332” and numBathsshould be assumed to be 1. • Assume that inputs to the constructor are valid inputs. • You mustminimize the amount of code written and maximize code reuse when writing these constructors. Hint: what keyword have we learned that allows you to call another constructor? Methods: All methods must have the proper visibility to be used where it is specified they are used. • Getters and settersfor each of the instance variables. Do not forget about the conditions stated for yearBuiltandnumBaths!If the inputs are not valid, do not change the value. • Optional: a helper method to determine whether a number of baths is valid and any other helper methods you may think of. However, remember these methods should NOT be able to be called from outside of this class. Neighborhood.java This file defines aNeighborhood object. This class will have some instance variables and functionality designed to store House objects. Variables: All variables must not be allowed to be directly modified outside the class in which they are declared, unless otherwise stated in the description of the variable. The Neighborhoodclass must have these variables: • numHouses - a value that representsthe number of Houses in the neighborhood, represented by an integer • houses- a value that represents the Housesstored in the neighborhood, represented by an array Constructor(s): • A constructor that takes in a Housearray. Make sure to initialize numHousesfield to the correct value based on the house array parameter. • A constructor that takes in no parameterbut initializes numHousesto 0 and houses to an array of size 5 with no Houseobjects. • You must minimize the amount of code written and maximize code reuse when writing these constructors. Hint: what keyword have we learned that allows you to call another constructor? Methods: All methods must have the proper visibility to be used where it is specified they are used. • displayNewHouses • Given a year, display all Houses that were built during that year or later. • Print each House on a new line in the format “House located at {address} was built in {year}, has {numBaths} number of bathrooms, and {has/has not} been renovated recently.” • {has/has not} depends on the value of isRenovated • addHouse • Given an index and a House parameters, add thatHouse to the given index in the houses array and return the House that was previously stored at that index. Remember to update numHouses if you are increasing the number of houses stored in the array. • If that index was already occupied by a House, do not update numHouses. • If the index wasinvalid, the input House was null, or there was no house previously stored at that index, simply return null. • removeHouse • Given an index,remove aHouse from that index in the houses array and return the House that was previously there. Remember to update numHouses. • If that index was not occupied by a House, return null and do not update numHouses. • If the index was invalid, simply return null. • isFull • If every spot in the neighborhood is occupied by a House, return true. Otherwise, return false. • Getters and Setters as necessary. • Optional: any helper methods you may need. However, remember these methods should NOT be able to be called from outside of this class.
Sep 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here