Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Subdivision part 1 Sophie, Sally and Jack's financing for their real estate development business is going well. The next step is to create a prototype

Subdivision part 1

Sophie, Sally and Jack's financing for their real estate development business is going well. The next step is to create a prototype Subdivision class.

Write a class Subdivision

A Subdivision has only one instance variable, an ArrayList of House elements

Subdivision has a single, no argument constructor.

Accessors

House get(int position) returns the House occupying the given position in the Subdivision. The first house added to the Subdivision is position 0, the next house added is position 1, etc.

ArrayList < House > list() returns the list of houses in this subdivision. The houses in the returned list are in the same order as they were added to the subdivision.

ArrayList < House > listByArea(double floor, double ceiling) returns the list of houses whose total area is greater than or equal to floor, and less than or equal to ceiling. The houses in the returned list are in the same order as they were added to the subdivision. If there are no such houses in the subdivision, an empty list is returned.

ArrayList < House > listByBedrooms(int floor, int ceiling) returns the list of houses that have greater than or equal to floor bedrooms, and less than or equal to ceiling bedrooms. The houses in the returned list are in the same order as they were added to the subdivision. If there are no such houses in the subdivision, an empty list is returned.

int size() returns the number of houses in the Subdivision

String toString() returns a String representation of the Subdivision

Mutators

boolean add(House houseToAdd) adds a House to the Subdivision. add returns true if the House was added successfully, false otherwise.

Test Class

Write a class Phase1 that has only a main method. Phase1 is a console program that asks the user for the number of houses to be added to a Subdivision. For each House, the program asks the user for that House's information and adds it to the Subdivision . When all the houses have been entered, it prints the size of the Subdivision , and the contents of Subdivision ordered by position. The program asks the user for floor and ceiling values for total area, and displays the houses whose total area is between or equal to those values. It similarly asks the user for floor and ceiling values for the number of bedrooms, and displays the houses whose number of bedrooms is between the floor and ceiling (inclusive).

Grading Elements

  • Subdivision has a single instance variable of type ArrayList
  • Subdivision has a single no argument constructor
  • All methods return the designated type and have correct signatures
  • All methods return the correct values
  • Returned lists have the proper order of House elements
  • Accessors do not change the state of the Subdivision (i.e., they do not change the instance variable)
  • add places Houses into the Subdivision at the correct position
  • Phase1 provides the specified operation to test Subdivision

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago