Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Questions 1 and 2 are based on the following scenario: An object-oriented application, written in Java, is being developed for simulating a heating system for
Questions 1 and 2 are based on the following scenario: An object-oriented application, written in Java, is being developed for simulating a heating system for a small building in Canada. The application has two major classes: Radiator and Room. The following properties apply to the classes: . . A Radiator heats one Room. A Room can be heated by zero or up to 2 unique Radiators The Radiator class has the state: radiatorID (int) and isTurnedon (boolean). has a constructor that does not accept any arguments. generates unique integer values for the radiatorID starting from 1000 and increases in increments of 10 for each successive Radiator object. has its state as turned off initially. has one accessor method for the radiatorID has one public method, heats (Room rm), that associates a Room object with a Radiator object. No return values. The Room class has the state: roomName (String), seatingCapacity (int) and numRadiators (int). has a constructor that accepts a roomName and initialises the seatingCapacity to a default value of 15. has one public method isHeatedBy (..) that accepts and associates a Radiator object with the Room object. This method returns a String containing one of the following messages indicating whether the Radiator was successfully associated with the Room or not: "Radiator already added to room. "Radiator successfully added to room. "Cannot add Radiator. Room has maximum number of radiators." Question 1 (10 marks): Classes, State, Behaviour Write Java code for the Radiator class. Ensure that information hiding principles are enforced. Include additional variables as necessary for implementing the functionality described for the class. [10 marks]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started