Question: THE PROGRAM SHOULD BE WRITTEN IN JAVA. Untitled File Edit Format View Help You will use inheritance to create a general Player Class that can

THE PROGRAM SHOULD BE WRITTEN IN JAVA.THE PROGRAM SHOULD BE WRITTEN IN JAVA. Untitled File Edit Format ViewHelp You will use inheritance to create a general Player Class that

Untitled File Edit Format View Help You will use inheritance to create a general Player Class that can be used for a variety of games. For this assignment, in addition to creating the layer Class, you will also create a sub-class called Racer -A Racer object will either be a slow but steady racer or a fast and curious racer A slow but steady racer always moves forward but only moves one or two positions each turm. Afast and curious racer moves one to four positions for each tum but can go forward and backwards. The Racer objects moves along a straight race track of a given size moving forward and backwards if appropriated) taking tums until one the objects wins (gets to the last position of the track). Do not use any data structures. The Racer Class A Racer object has three attnbutes and sets name, position, maxPosition to it's superclass: +character - which is represented by an integer 1 means the racer is slow but steady always go forward moving 1 or 2 steps each tum 2 means the racer is fast and curious meaning they can move from 1 to 4 steps each tum but this can be going forward AN +steps an integer which represent how many spots a racer can move in one tum: A slow but steady racer goes at rate of 1 or 2 steps a tun. Afast and curious racer goes at rate or to 4 steps a tum. D going backwards. direction-aninteger which represents whether a racer goes forward only or forward and backwards.A slow but steady racer only goes forward no matter what (set to 1). Afast and curious racer goes backwards and forwards (set to 0) The constructor has three parameters (name, character, maxPosition). It uses super to set the name and the maxPosition for the Racer. It also uses the character int to set the steps and distance (I represents a slow but steady racer and 2 represents a fast and curious racer). The Racer class overrides the Player Class's move method. The move method in the Racer class takes in both the direction and number of steps to move. Direction will either be inputted as 0 (go backwards) or 1 (go forward).As well, number of steps to move will either be 1 or 2. You will use the Racer's own steps and direction attributes to work with the inputted move method parameters. The Race class overrides the Player class's move method. The Race class wil take both a direction and a number of steps to move. If the direction is backwards (1) then you need to make sure that moving won't take the Racer out of bounds. The Racer object should not move below 1 (move to 1 if the move would take the racer out of bounds) Ifthe direction to move is forward and number of spots to move is larger than the maxPosition, then don't move. You need to reach the final position (maxPosition) with an exact number For example, if the Racer is at spot 4 with a maximum size of 5, andit is told to move 2 spots. This is higher than the max size, so the Racer will stay where it currentdy is. It needs to be told tomove 1 spot to get the final spot (maxPosition). Then create a Racer demo class. You will read in the attributes of the two racer objects. Then you will continue to read in a direction and number to move for racer object 1, followed by a direction number to move racer object 2 while keeping track of each racet Direction will always be entered in as 0 (backwards) or 1 (forward) no matter what type of character each Racer is. Move will always between 1 and 4 regardless of the character type of the Racer You should handle all imput limitations in the Racer Class. -After eachracer moves, check to see if there is a winner and add the moves (direction and read in steps) to a String that will be printed out after a winner tie is declared. Continue to read in numbers representing direction move for each racer until a winner is declared. Then print out the String with the pairs of direction moves for eachracer and who won (or tied) and in (n) umber of tums. See the output. Please note, that after the imput output table there are two mages that goes with the rst and second input output examples so you can see visual y how the two racers move alona straight line This is just to show you visually what happens after each move -INPUT Rapid 2 14 Speedy 2 1412141301111312141412011211121111 -OUTPUT R: 12 S: 14R:13S:01R:11S: 13 R: 12 S: 14R: 14 S: 12R:01S: 12R:11S: 12R: 11 S: 11 Tie! in rounds! Activate Windows Go to PC settings to activate Windows Codio Twitch L15.CodingThew Untitled-Notepad 11/7/2018 Untitled File Edit Format View Help You will use inheritance to create a general Player Class that can be used for a variety of games. For this assignment, in addition to creating the layer Class, you will also create a sub-class called Racer -A Racer object will either be a slow but steady racer or a fast and curious racer A slow but steady racer always moves forward but only moves one or two positions each turm. Afast and curious racer moves one to four positions for each tum but can go forward and backwards. The Racer objects moves along a straight race track of a given size moving forward and backwards if appropriated) taking tums until one the objects wins (gets to the last position of the track). Do not use any data structures. The Racer Class A Racer object has three attnbutes and sets name, position, maxPosition to it's superclass: +character - which is represented by an integer 1 means the racer is slow but steady always go forward moving 1 or 2 steps each tum 2 means the racer is fast and curious meaning they can move from 1 to 4 steps each tum but this can be going forward AN +steps an integer which represent how many spots a racer can move in one tum: A slow but steady racer goes at rate of 1 or 2 steps a tun. Afast and curious racer goes at rate or to 4 steps a tum. D going backwards. direction-aninteger which represents whether a racer goes forward only or forward and backwards.A slow but steady racer only goes forward no matter what (set to 1). Afast and curious racer goes backwards and forwards (set to 0) The constructor has three parameters (name, character, maxPosition). It uses super to set the name and the maxPosition for the Racer. It also uses the character int to set the steps and distance (I represents a slow but steady racer and 2 represents a fast and curious racer). The Racer class overrides the Player Class's move method. The move method in the Racer class takes in both the direction and number of steps to move. Direction will either be inputted as 0 (go backwards) or 1 (go forward).As well, number of steps to move will either be 1 or 2. You will use the Racer's own steps and direction attributes to work with the inputted move method parameters. The Race class overrides the Player class's move method. The Race class wil take both a direction and a number of steps to move. If the direction is backwards (1) then you need to make sure that moving won't take the Racer out of bounds. The Racer object should not move below 1 (move to 1 if the move would take the racer out of bounds) Ifthe direction to move is forward and number of spots to move is larger than the maxPosition, then don't move. You need to reach the final position (maxPosition) with an exact number For example, if the Racer is at spot 4 with a maximum size of 5, andit is told to move 2 spots. This is higher than the max size, so the Racer will stay where it currentdy is. It needs to be told tomove 1 spot to get the final spot (maxPosition). Then create a Racer demo class. You will read in the attributes of the two racer objects. Then you will continue to read in a direction and number to move for racer object 1, followed by a direction number to move racer object 2 while keeping track of each racet Direction will always be entered in as 0 (backwards) or 1 (forward) no matter what type of character each Racer is. Move will always between 1 and 4 regardless of the character type of the Racer You should handle all imput limitations in the Racer Class. -After eachracer moves, check to see if there is a winner and add the moves (direction and read in steps) to a String that will be printed out after a winner tie is declared. Continue to read in numbers representing direction move for each racer until a winner is declared. Then print out the String with the pairs of direction moves for eachracer and who won (or tied) and in (n) umber of tums. See the output. Please note, that after the imput output table there are two mages that goes with the rst and second input output examples so you can see visual y how the two racers move alona straight line This is just to show you visually what happens after each move -INPUT Rapid 2 14 Speedy 2 1412141301111312141412011211121111 -OUTPUT R: 12 S: 14R:13S:01R:11S: 13 R: 12 S: 14R: 14 S: 12R:01S: 12R:11S: 12R: 11 S: 11 Tie! in rounds! Activate Windows Go to PC settings to activate Windows Codio Twitch L15.CodingThew Untitled-Notepad 11/7/2018

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!