Question: in java The Problem A museum has a number of rooms, each of which has several walls. Paintings are exhibited on some or all the
in java
The Problem A museum has a number of rooms, each of which has several walls. Paintings are exhibited on some or all the walls. Your task is to represent this system in an object-oriented manner. The museum, each room, each wall, and each painting has a name and each is represented in software by a class. This common property of the name is encapsulated in a super class named Entity; this class has a public constructor that takes the name of the entity as its only parameter. All other classes (Museum, Room, Wall, and Painting) are subclasses of Entity. Your system will thus have classes named Museum, Room, Wall, Painting, and Entity. The classes should be structured as shown below. Museum 1. A field to store the rooms 2. A constructor that sets the name 3. A method that returns a List (java.util) of Painting objects in the museum 4. A method to add a Room object. This method has a parameter for the name of the room and creates and returns the Room object created. Room 1. A field to store the walls 2. A constructor that sets the name 3. A method that returns a List (java.util) of Painting objects displayed in this room
4. A method to add a Wall object; This method has a parameter for the name of the wall and creates and returns the Wall object created. Wall 1. A field to store the paintings on this wall 2. A constructor that sets the name 3. A method that returns a List (java.util) of Painting objects displayed on this wall 4. A method to add a Painting object; this is called from the method (item 2) listed under Painting. Painting 1. A constructor that sets the name 2. A method to set the wall on which this painting is displayed; this calls the method (item 4) listed under Wall You will have to override toString() appropriately, throughout. Use generics wherever applicable. A Minimal Test The following code shows an idea of the expected functionality. Please remember that I will exercise your program with a more extensive test. public static void main(String[] args) { Museum museum = new Museum("M1"); Room room1 = museum.addRoom("r1"); Room room2 = museum.addRoom("r2"); Painting painting1 = new Painting("p1"); Painting painting2 = new Painting("p2"); Wall wall1 = room1.addWall("w1"); Wall wall2 = room2.addWall("w2"); painting1.setWall(wall1); painting2.setWall(wall2); System.out.println(wall1.getPaintings()); System.out.println(wall2.getPaintings()); System.out.println(room1.getPaintings()); System.out.println(room2.getPaintings()); System.out.println(museum.getPaintings()); } It produced the following output. [Painting p1 on wall w1] [Painting p2 on wall w2] [Painting p1 on wall w1] [Painting p2 on wall w2]
[Painting p1 on wall w1, Painting p2 on wall w2]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
