/* Driver.java -- contains main function for enhanced Painting program * In the long run, we like our main functions to be simple and concise * if possible. main() should delegate most of the work to the other * class files. */ import java.io.*; public class Driver { public static void main(String [] args) throws IOException { // Create 3 room objects -- illustrating use of different constructors. Room r1 = new Room(); Room r2 = new Room(); Room r3 = new Room(); // Let's practice using "get" and "set" functions. Notice that // setWidth() is a void function, meaning it does not return a value. // The following statements make the second room have the same width // as the first. double width = r1.getWidth(); r2.setWidth(width); // Output the cost to print each room. // Note that it is not necessary to store the painting cost in a // variable -- here we call the getCost() at the time we are ready // to print. // Also notice that we have a trade-off between making the program more // concise, but at the same time packing a lot of code in each statement. System.out.println("\nThe cost to paint each room is as follows:"); System.out.println(r1.getName() + " will cost $ " + r1.getCost()); System.out.println(r2.getName() + " will cost $ " + r2.getCost()); System.out.println(r3.getName() + " will cost $ " + r3.getCost()); } }