2 1 Arcadegame 10 Arcade Games Are Initially Split Into Two Types Of Game Cabinet Games E G Pinball Pac Man Ligh 1 (163.17 KiB) Viewed 58 times
2.1 ArcadeGame (10%) Arcade games are initially split into two types of game: cabinet games (e.g. pinball, pac-man, lightgun games, etc.) and active games (e.g. things that require active movement, such as pool, darts, air hockey, etc.). There is also a third type of game, virtual reality games, that further ex- tend the active games class (more on that in Section 2.3). To start with however, you will need to begin by creating an abstract base class for Arcade Game that will form the basis for the cab- inet game and active game subclasses. All arcade games have a name, serial number and price to play games. • Game IDs should uniquely identify a specific game. IDs are 10 characters long and may contain a mixture of numbers and letters. • Price per play is stored as a whole number in pence (e.g. if a game costs £2 to play, this would be stored as 200). You are required to write an abstract class called ArcadeGame. This class should include fields for the ID, name and price per game of an arcade game. Your class should have a single con- structor that takes values for each of those three fields and it should check that the provided ID is valid. If it is not, it should throw an InvalidGame IDException (you will need to implement your own Exception for this). Further, your ArcadeGame class should have accessor methods for all fields and an abstract method called calculatePrice(boolean peak) that returns an int and takes a boolean as input (true for peak, false for off-peak). The purpose of this method is that subclasses can over- ride it to return the correct price depending on whether it is used during peak/off-peak hours (more on that in Section 2.2).