Question 4 Tic-tac-toe (also known as noughts and crosses) is a game for two players, X...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 4 Tic-tac-toe (also known as noughts and crosses) is a game for two players, X and O, who take turns marking the spaces in a 3x3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game. The game ends in a draw if neither player is able to achieve a winning row after all spaces in the grid have been filled. The following example game, as illustrated in Wikipedia, is won by the first player, X: 96 TX qX X X X X # ax OLX Figure 2: Tic-tac-toe a) Provide the complete source code for a Tic-tac-toe game which allows two players to play on against each other. 10 hea Int pt *pt The game must be played in the console. You need to allow each player to take their turn by having them input the position at which they will make their mark, and you must display the updated game grid after each turn. Output a message when the game is over indicating who won, or if the game was a draw. Your solution must be object-oriented and you should separate the presentation layer from the game logic. b) Provide a set of unit tests which verify that your solution works correctly. (20 marks) (18 marks) [Total Marks 38] Question 4 Tic-tac-toe (also known as noughts and crosses) is a game for two players, X and O, who take turns marking the spaces in a 3x3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game. The game ends in a draw if neither player is able to achieve a winning row after all spaces in the grid have been filled. The following example game, as illustrated in Wikipedia, is won by the first player, X: 96 TX qX X X X X # ax OLX Figure 2: Tic-tac-toe a) Provide the complete source code for a Tic-tac-toe game which allows two players to play on against each other. 10 hea Int pt *pt The game must be played in the console. You need to allow each player to take their turn by having them input the position at which they will make their mark, and you must display the updated game grid after each turn. Output a message when the game is over indicating who won, or if the game was a draw. Your solution must be object-oriented and you should separate the presentation layer from the game logic. b) Provide a set of unit tests which verify that your solution works correctly. (20 marks) (18 marks) [Total Marks 38]
Expert Answer:
Answer rating: 100% (QA)
Question 4a python class Player def initself mark selfmark mark def mak... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Googles ease of use and superior search results have propelled the search engine to its num- ber one status, ousting the early dominance of competitors such as WebCrawler and Infos- eek. Even later...
-
What are some Marketing Strategies for Delivering Objectives Polestar (Car company) has used or using?
-
What is meant by an optimum currency area or bloc?
-
a. $20 000 is invested in an account that pays interest at 2.4% per annum. The interest is added at the end of each year. After how many years will the value of the account first be greater than $25...
-
Pick a product like Cadillac or Sara Lee Deli products or service like Mr. Clean Performance Car Wash or a car and home insurance company that is offered in a limited number of countries. Assess the...
-
The City of Sweetwater maintains an Employees Retirement Fund, a singleemployer, defined benefit plan that provides annuity and disability benefits. The fund is financed by actuarially determined...
-
Based on the above case study, "Want-2-Work", present each of the following: 1) ER diagram 2) Relational model 3) Rules or assumptions made 4) Between 3 or 5 queries using the relational model...
-
If you construct a bond portfolio with five 6% coupon (semiannual payment), duration of 2.79 years, 3-year maturity bond sells at par ($1,000) and six 1-year zero coupon bond sells for $950. (a)...
-
In the figure 91-4.7 nC is to the left of 92=2.4 nC. Point P is between 9 and 92 while point G is to the right of 92. The charge q is d= 0.2 m meters from point P and 0.44 m from point G. The charge...
-
COVID - 1 9 has only compounded the emotional, physical, and mental strain on a workforce that was already reporting burnout before the pandemic. The cracks continuously show in that healthcare...
-
The most interesting concept I've learned is about real estate investments. There's so much money to be made in all the different types available. Having worked at Warner Center, I could only imagine...
-
Examine the role of stakeholder engagement in the context of sustainable business management. How do businesses effectively identify and address the diverse needs and expectations of stakeholders,...
-
The organization has significant limitations within the processing power that exists on the current controllers. The controllers still fall within the support lifecycle from the industrial control...
-
in real estate settlement the recording charge the buyer usually pays for ? Explain
-
Find out the Functional and Non-Functional Requirements: 1) have a two-second maximum response time for predefined queries and a ten-minute maximum response time for ad hoc queries. 2) include the...
-
What are the typical record-at-a-time operations for accessing a file? Which of these depend on the current file record?
-
Several years ago, Revnon Co. acquired a 60% interest in Aumets Inc. at book value. During 2012 and 2013, intragroup sales of merchandise amounted to $120,000 and $180,000. On December 31, 2012, and...
-
The statement of financial position of Column Ltd. in Belize dollars, at December 31, 2013, was as follows: On January 1, 2011, Centaur acquired all the shares in Column, giving in exchange 50,000...
-
Campbell Ltd. invested in a joint venture by providing cash of $160,000. Campbell obtained a 22% interest in the joint venture based on its contribution. During the year, the joint venture earned...
-
Let \(X, Y, X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}, n \geqslant 1\), be random variables. a) If, for all n > 1, Xn Yn and if (Xn, Yn) (X, Y), then XIL Y. b) Let X Y such that X, Y ~ B1/2 = (80...
-
Let \(X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}, n \geqslant 1\), be two sequences of random variables. a) If \(X_{n} \xrightarrow{d} X\) and \(Y_{n} \xrightarrow{\mathbb{P}} c\), then \(X_{n} Y_{n}...
-
Let \(X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}^{d}, n \geqslant 1\), be two sequences of random variables such that \(X_{n} \xrightarrow{d} X\) and \(X_{n}-Y_{n} \xrightarrow{\mathbb{P}} 0\). Then...
Study smarter with the SolutionInn App