Please log into cs.bridgewater.edu and navigate to /csci102/hw/mar24. Write a program that satisfies the following requirements.
Program Specifications
Write a class named CommercialBuilding
that includes the following.
- The class should include fields for the building’s address (String), square footage (double), and number of units in the building (int).
- The class should set all of its fields in the constructor using arguments passed to the constructor.
- The class should override
toString()
which should return a sensible string. - The class should override
equals()
and consider two CommercialBuildings objects equal if they have the same address. - The class should override
hashCode()
.
Write a class named Driver
as specified below.
- The class has a method named
createCommericalBuilding()
. The method should have no parameters. The method should ask the user for the data needed to create an instance of the CommercialBuilding class, then use that data to create and return an instance of the CommercialBuilding class. - In the
main()
method, callcreateCommercialBuilding()
twice and print whether or not the two objects returned fromcreateCommercialBuilding()
are equal. Then print “McG is my favorite professor”.
© 2021, Eric. All rights reserved.