Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extending our Design For this assignment, we will expand on last week's assignment in two ways: 1. You will now be able to play

image

Extending our Design For this assignment, we will expand on last week's assignment in two ways: 1. You will now be able to play against the computer, where the computer will follow some predefined strategy 2. You can now play a timed version of the game: if the game lasts longer than one minute, the winner is whoever had the most points at the time. You will implement the computer player as an inherited class from the base Player class. This will help differentiate the computer player from a human one, which will be in its own class. You will also design a PlayerFactory class, that will instantiate the correct Player class. For the timed version of the game, you will implement this as a Proxy pattern on the Game class. This class will use all the same methods as the Game class, but will keep track of time and when time is up, determine a winner. Playing Against the Computer In order for the computer to make decisions in this game, the computer must have some kind of strategy. For this assignment, have the computer use the following strategy: given the computer's score x, the computer will hold at the lesser of 25 and 100 - x; otherwise, the computer will roll. This strategy should be implemented in a new class, called ComputerPlayer, that inherits from the Player base class. To determine what kind of players to use, your program should now accept two arguments, a --player1 and --player2 argument, each of which can be "human" or "computer". Yes, your computer can potentially have two computer players playing against one another. Now that you have a new class, you should design a Factory class that will instantiate either a human or computer player, depending on the input. The Game class should use this Factory when initializing the game Timed Version of Pig Your next task is to write a Proxy to the Game class, called TimedGameProxy, which will follow all the same exact rules of Pig as before, but will introduce a timed aspect: the game will continue until either someone scores 100, or one minute has elapsed since the start of the game. This proxy should keep track of the time the game starts, and should check that no more than one minute has gone by since then at every step. In order to activate this feature, your program should take in a --timed parameter.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management and Cost Accounting

Authors: Colin Drury

8th edition

978-1408041802, 1408041804, 978-1408048566, 1408048566, 978-1408093887

More Books

Students also viewed these Programming questions

Question

For any events A and B in a sample space, we have (A B) = AB.

Answered: 1 week ago

Question

What percent is $1.50 of $11.50?

Answered: 1 week ago