The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
LiFiUnit7.java
Provide a driver class that demonstrates this house class. You are to use the main method provided below exactly with the exception of the class name for house, follow the naming convention outlined above.
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
LiFiHouse house1, house2; //New horses
//Create house 1 using default constructor
house1 = new LiFiHouse();Â
house1.print(); //print house 1 with default values
String street, city, state, zipCode;
int number;
System.out.println("House 1 Information");
System.out.print("Please enter house number: ");
number = stdIn.nextInt();
stdIn.nextLine();
System.out.print("Please enter Street: ");
street = stdIn.nextLine();
System.out.print("Please enter City: ");
city = stdIn.nextLine();
System.out.print("Please enter State: ");
state = stdIn.nextLine();
System.out.print("Please enter ZipCode: ");
zipCode = stdIn.nextLine();
System.out.println();
//use method call chaining to set values
//and print results for house 1
house1.setNumber(number).setStreet(street)
.setCity(city).setState(state).setZipCode(zipCode).print();
System.out.println("House 2 Information");
System.out.print("Please enter house number: ");
number = stdIn.nextInt();
stdIn.nextLine();
System.out.print("Please enter Street: ");
street = stdIn.nextLine();
System.out.print("Please enter City: ");
city = stdIn.nextLine();
System.out.print("Please enter State: ");
state = stdIn.nextLine();
System.out.print("Please enter ZipCode: ");
zipCode = stdIn.nextLine();
System.out.println();
//create house 2 using 5 parameter constructor
house2 = new LiFiHouse(number, street, city, state, zipCode);
//print house 2
house2.print();
}
This demonstration driver does not call all accessor and mutator methods but it is normal to create them regardless of an immediate use. They may be needed in the future.
Sample output is provided below. Be sure to mimic it exactly except for values entered.