Reply to your classmates\' post about the online game https://gamegraveyard.net/
ID: 3920927 • Letter: R
Question
Reply to your classmates' post about the online game https://gamegraveyard.net/dos/theme_hospital/play-online with constructive remarks and/or questions.
1. One class could be the mouse pointer. The object is the mouse itself and some attributes might be currentXPosition and currentYPosition. Some methods could be getCurrentXPosition() and getCurrentYPostion() to get the x and y coordinates of where the mouse is on screen. Another method could be rightMouseClicked() and leftMouseClicked().
2. Each object is created at runtime using a constructor which builds the object and initializes default values.
3. I believe various data structures are used to store and organize information for each object in the game in the most memory efficient manner.
4. Yes, because OOP is used for most games today. Its a way of modeling everything around us at a high level.
Explanation / Answer
1. This game involves a lot of user interaction using mouse clicks. Hence, I would assume that the all the buttons are clickable and whenever they are clicked, each of the buttons trigger a different action. Hence, the mouse is the point of interaction here and the pointer's location is determined with its current x and y position. Addition, we would also need to listen to mouse left click and right click to trigger specific actions.
2. I believe that the whole game is done by building different classes for each activity.And the objects are generally intitalized using constructors.
3. To make the game more effecient in terms of memory usage and time consumption, this game would need to use a combination of data structures and algorithms. Some common data structures used would be Arrays, Trees, Stacks, etc.
4. Most of the softwares, games, etc built nowadays are based on Object Oriented design which involves Inheritance, Polymorpishm, Enscapsulation. The reason behind using OOP is because it is highly relatable to real world.