package designingclasses; /** * * @author Mayelin */ public class DesigningClasses { /** * @param args the command line arguments */ public static void main(String[] args) { // Create three Rectangle objects. Rectangle kitchen = new Rectangle(); Rectangle bedroom = new Rectangle(30, 20); Rectangle den = new Rectangle(bedroom); System.out.println("Den length: " + den.getLength()); kitchen.setLength(20); kitchen.setWidth(15); bedroom.setLength(40); bedroom.setWidth(10); System.out.println("The kitchen's area is: " + kitchen.getArea()); System.out.println("The bedroom's area is: " + bedroom.getArea()); System.out.println("The total area is: " + (kitchen.getArea() + bedroom.getArea() + den.getArea()) ); System.out.println("Length: " + kitchen.getLength() + " Width: " + kitchen.getWidth()); System.out.println("Kitchen: " + kitchen.toString()); Rectangle livingRoom = new Rectangle(den); System.out.println("Are the two objects the same? " + (livingRoom == den)); System.out.println("Do they have the same data? " + livingRoom.equals(den)); den.setLength(18); System.out.println("Do they still have the same data? " + livingRoom.equals(den)); System.out.println("Den: " + den.toString()); System.out.println("Living Room: " + livingRoom.toString()); } }