Extending our Design For this assignment, we will expand on last week's assignment in two ways:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Giving a suitable example, explain the effect in C++ of qualifying a member function (method) with virtual. [3 marks] (e) Recode the following Java code in C++. Minor syntactic errors will not be...
-
123 Compare the purely graphical properties of these two notations, and the ways in which the graphical properties of each display correspond to the information structure being defined. Describe...
-
After graduation, you begin your new job. Naturally, you're already thinking about retirement. You estimate you'll need $2 million to comfortably stop working, 40 years from now. If market returns...
-
Tara's Card and Novelty Shop is a retail card, novelty, and business supply store. Tara's Card and Novelty Shop commenced business on April 1, 2019. The firm purchases merchandise on open account....
-
i. Plot the data in Table 22.1 for increase in propene concentration with time. ii. Calculate the rate after 10 minutes (when the propene concentration is 0.50 mol dm 3 ) by drawing a tangent. b. Use...
-
Vibration spectra can have many frequency peaks. What is key to simplifying the analysis of the number of peaks of interest?
-
A block of mass m = 1.62kg slides down a frictionless incline (Figure 2-A). The block is released a height h = 3.91, above the bottom of the loop. (a) What is the force of the inclined track on the...
-
1. The fighters of the Ultimate Fighting Championship (UFC) filed suit against the UFC, alleging that the UFC unlawfully monopolized the output and input markets in mixed martial arts. In particular,...
-
What Are Empirical/Research Articles? Describe the resource assigned to you including two examples of how this resource will support your successful completion of the capstone project?
-
a). (5 marks) Fill in the relationship between each pair of the functions below. (Use N, O, e, or none of the above) n n+n/log(n) n (1) 30030 n* log(n) (2/3)" 2" b). (5 marks) Answer following...
-
If Marcy can make \(70 \%\) of free throws in a basketball game, what is the probability that she makes five of the next six free throws?
-
Suppose you are taking a true-false test with ten questions. If you guess at the answers on this test, find the probabilities in Problems 19-22. Exactly nine correct answers
-
Consider the experiment of selecting three items (without replacement) from a sample space of 100 , of which 5 items are defective. Let \(A_{1}=\{\) first item selected is defective \(\}, A_{2}=\)...
-
Find the binomial probabilities in Problems 3-10. \(n=7, X=5, p=0.10\)
-
The Weather Channel makes accurate predictions about \(85 \%\) of the time. Use this information to answer the questions in Problems 12-13. What is the probability that Weather Channel meteorologists...
-
Using the window design method, it is desired to design an FIR Low Pass Filter with a minimum stop-band attenuation of 40 dB, and to have a transition width of (0.17 ). Determine: ( 0.17 a) The most...
-
Determine the reactions in supports A and D and connections B and C. Sketch its shear and moment diagram and determine the magnitude ankoration of the maximum shear and moment for every member. 18 3...
-
Incorporated Finance plc is a finance company having one hundred branch offices in major towns and cities throughout the UK. These offer a variety of hire purchase loan facilities to personal...
-
A local authority, whose area includes a holiday resort situated on the east coast, operates, for 30 weeks each year, a holiday home which is let to visiting parties of children in care from other...
-
The following information relates to a manufacturing process for a period: 10 000 units of output were produced by the process in the period, of which 420 failed testing and were scrapped. Scrapped...
-
Birth weights in the United States are normally distributed with a mean (in grams) of 3420 g and a standard deviation of 495 g. If you graph this normal distribution, the area to the right of 4000 g...
-
Is the distribution of those digits a normal distribution? Why or why not?
-
Many states have lotteries that involve the random selection of digits 0, 1, 2, ,
Study smarter with the SolutionInn App