1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zlopas [31]
3 years ago
7

Write a program that allows two players to play a game of tic-tac-toe. Use a two dimensional char array with three rows and thre

e columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that - Displays the contents of the board array - Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and column number. - Allows player 2 to select a location on the board for an O. The program should ask the user to enter the row and column number. - Determines whether a player has won, or a tie has occurred. If a player has won, the program should declare that player the winner and end. If a tie has occurred, the program should say so and end. Player 1 wins when there are three Xs in a row on the game board. The Xs can appear in a row, in a column, or diagonally across the board. A tie occurs when all of the locations on the board are full, but there is no winner.
You need to code programing challange question 18 (Tic Tac Toe Game) from Chapter 7 and add following feature in it.
1. Add two playing options. That is player can play with other player or with computer.
2. Add difficulty level (Easy, Medium and Hard) when playing against computer.
3. You should store the history of game results in a file and whenever game start you should load the history from the file.
4. Your game should present following menu.

Game Menu

1. Play
2. Game Results
3. Quit

If user select 1 then following menu should be shown

1. Play with Computer
2. Play with Other Player
3. Go Back

If user selects 3 then you should go back and display previous menu screen.
If user selects 1 the show following menu

Please select difficulty
1. Easy
2. Medium
3. Hard
4. Go Back

When user selects the desired difficulty then you should take the username (first and last name) from the user start the game
and user should be able to play with computer. Keep in mind in Easy difficulty level player should be able to easily beat the
computer where as in hard difficulty it should be very difficult for player to win.
Once game has been finished store the result in a file (You can give whatever name you want to) in following format

Name, Opponent Name, Winner, Date

For example if Majid Ali played game against computer with medium level and he wins then file should contain record as following

Majid Ali, Computer, Majid Ali, Medium, 22-August-2020

For example if Majid Ali played game against Hamza Abbas and Hamza wins then file should contain record as following

Majid Ali, Hamza Abbas, Hamza Abbas, None, 20-August-2020

When user selects 'Game Results' from the main menu then all the contents you saved in the file should be display to the screen in following format

Player 1 Player2 Winner Level Date
================================================
Majid Ali Computer Majid Ali Medium 22-August-2020
Majid Ali Hamza Abbas Hamza Abbas None 22-August-2020

Please do proper input validation at each level.
Computers and Technology
1 answer:
Katyanochek1 [597]3 years ago
7 0

Answer:

Explanation:

i think it is easy:

1- you declare 2d array

2- fill it with *

3- declare player1Turn =true

4- declare player2Turn =false

5- make while loop where not finished

BS:not Finished would be function return bool that checks the condtions

6-if player1Turn

6.1- player1Turn =false

6.2- player2Turn =true

6.3- call function called play with "player1","X" as args

6-else if player2Turn

6.1- player2Turn =false

6.2- player1Turn =true

6.3- call function called play with "player2","O" as args

5- end while loop

You might be interested in
Write a statement that declares an anonymous enumerated type with the enumerators SMALL, MEDIUM, and LARGE.
MArishka [77]

Enumerated data types are simply data types that contains a set of named values called enumerators.

The required statement is <em>enum {SMALL, MEDIUM, LARGE} ssize;</em>

The syntax of the anonymous enumerated type is:

<em>enum {List of enumerators} name of variable;</em>

From the question, the enumerators are SMALL, MEDIUM, LARGE.

The name of the variable could be ssize

Hence, the anonymous enumerated type statement is:

<em>enum {SMALL, MEDIUM, LARGE} ssize;</em>

<em />

Read more about enumerated data types at:

brainly.com/question/15518342

4 0
2 years ago
After reviewing the various types of network connections available, a client chooses a network connection that is considered to
andriy [413]

Answer:

Wired Network Connection

Explanation:

The two major types of connection is <em>Wired</em> and <em>Wireless </em>connection. The wired connection helps to transfer data between two devices using <em>Ethernet network cable</em>. The wireless connection on the other hand transfer data between endpoints using <em>microwave signals or radio frequency</em>.

<em>Wired connection</em> is preferred over <em>Wireless</em> because of interference which could be caused by other networks as well as wall obstructing the connection.

7 0
4 years ago
Why the computer is known as versatile and diligent device ? explain.<br>​
Scrat [10]

Answer:

Computer is called versatile and diligent device because it is used in almost all the fields for various purposes and it can perform the task repeatedly without loosing its speed and accuracy for long time.

5 0
2 years ago
Which statement correctly differentiates how to use list and table styles?
irina [24]
What statement please explain correctly
5 0
3 years ago
Read 2 more answers
In the given switch statement, what will be displayed if the value of var is 3? switch(var) { case 1: System.out.println("Apple"
olga_2 [115]

Answer:

The output of the given program is  

Peach Pear Pineapple.

Explanation:

since the value of var is so control will move to the case 3 directly and executed the statement inside the case 3 so it will print "Peach" in window after that their is no break statement in the case 3 the control moves the case 4 and executed the statement inside the case 4 so it will print "Pear" in window again there is no break statement in the case 4 the control moves the case 5 and executed the statement inside the case 5 so it will print "Pineapple".Finally, the break statement is reached the execution of the program is stopped.

3 0
3 years ago
Other questions:
  • Imagine that you are an independent filmmaker making a feature-length narrative film in the United States, with a variety of bot
    11·2 answers
  • A system will always require what power connector?
    8·1 answer
  • Which of the following should you do first when planning your career
    11·1 answer
  • Which of the following best supports the utilization of environmental engineers on a civil engineering hydraulic project?
    13·1 answer
  • Which leader of the Jamestown colony am I?
    15·2 answers
  • Class function which is called automatically as soon as the object is created is called as __
    6·1 answer
  • I need help converting this to python but i have no idea how to.
    12·1 answer
  • Plz help me I need help​
    6·1 answer
  • Anything a person writes or creates is __________
    6·2 answers
  • Who likes my meme? :)
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!