WITHOUT USING ARRAYS Programming Project The Opoly Game For

WITHOUT USING ARRAYS

Programming Project: The Opoly Game

For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to:

Break down a problem into smaller, easier problems.

Write Java methods that call upon other methods to accomplish tasks.

Learn the coding practice of writing methods that perform a specific task.

Opoly works this way: The board is a circular track of variable length (the user determines the length when the game app runs). There is only one player, who begins the game at position 0.
Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.


The circular nature of the board means that if the player advances to a position beyond the board size, the position will \"wrap\" around to the beginning. For example, if the board size was 20, the first position would be 0, and the last position would be 19. If a player was on position 18 and the spin result was 4, the new position would be 2. Although there are several ways to calculate this, a convenient way uses modular arithmetic: (position + spinResult) mod boardSize.


Although the board is circular, you should draw the state of the board as a single \"line\", using an \'o\' to represent the current player position, and * represent all other positions.
Thus if the board size is 10, then this board drawing:


means that the player is at location 2 on the board.

Here are the other Opoly game rules:

If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.

If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).

If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,

Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it\'s possible for the reward amount to become negative.


Here is the driver class for the game:


Here is a sample run:



REQUIRED CODE STRUCTURE:
Your Opoly class must include the following methods (in addition to the Opoly constructor) and must implement the method calls as specified:

playGame - The top-level method that controls the game. No return value, no parameters. Must call drawBoard, displayReport,spinAndMove, isGameOver.

spinAndMove - spins the spinner and then advances the piece according to the rules of the game. No return value, no parameters. Must call spin and move.

spin - generates an integer value from 1 to 5 at random- all equally likely. Returns an integer, no parameters.

move - advances the piece according to the rules of the game. No return value, takes an integer parameter that is a value from 1 to 5.

isGameOver - checks if game termination condition has been met. Returns true if game is over, false otherwise. No parameters.

drawBoard - draws the board using *\'s and an o to mark the current board position. Following each board display you should also report the current reward. No return value, no parameters.

displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward. No return value, no parameters.


ALSO REQUIRED: Comment each method with a brief description of what it does.

Development tips:

Define the attributes for the Opoly class. At any instant, what is the \"state\" of the board? What data do you need to keep track of to give the final report? The answers to these questions will help you define the attributes of the Opoly class.

Write the Opoly constructor. Infer this definition from the call in the OpolyDriver code.

Write \"stub code\" for all of the methods listed above. Stub code is the method header with no body. You can simply return some value if required, such as return true; for a method that returns a boolean. Of course, methods that return void don\'t need a return statement. Then, write the playGame method calling the methods outlined above. You can then start to implement the methods so that you can run the code, increasing the functionality a little at a time. (This is called incremental development). Another simplification to start with: just implement the rule that increases the reward by 100 every time you circle the board. You can add the other rules later.


Think of what the playGame method does in pseudocode:


Enter your Opoly class code in the box below:

NOTE: you may NOT use any import statements in your class. Use the Math class random method to generate your random numbers. Do NOT import the java.util library. Note: you do not need an array to solve this problem.

Solution

#include #include #include #include #include using namespace std; // Determines if the string is a number bool isNumeric(string pszInput); int main () { // Hold the line in the file string line; // Open the file ifstream myfile (\"example.txt\"); if (myfile.is_open()) { // While the file is good while (myfile.good() ) { // Get the current line in the file getline (myfile, line); // Verify that the line is an integer if (isNumeric(line)) { // Convert \'line\' to an integer and calculate if (atoi(line.c_str())%2 == 0) { cout << \"Even\ \"; } else { cout << \"Odd\ \"; } } } myfile.close(); } else { cout << \"Unable to open file\ \"; } // Exit return 0;
WITHOUT USING ARRAYS Programming Project: The Opoly Game For this assignment, your job is to create a simple game called Opoly. The objectives of this assignmen
WITHOUT USING ARRAYS Programming Project: The Opoly Game For this assignment, your job is to create a simple game called Opoly. The objectives of this assignmen

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site