Your Perfect Assignment is Just a Click Away
We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Coding Question

Coding Question

Coding Question
Objective: The main objective of this assignment is checking the students’ ability to work with ADTs. In this week’s assignment, you will be writing the interface of an ADT in order to conform to the requirements of a larger application.

Description: You have been tasked with implementing a program that can read chess games from a file and detect whether the initial moves (opening) matches any of the stored openings (also read from a file). Note that the program does not compile successfully as it is missing ADT definitions which you will implement.

For example, the position in Figure 1, which corresponds to the first 5 moves, is called the “Italian Game”.

Figure 1

You must utilize 2 ADTs (Opening, Game) for the tasks described in next section.

Opening must have the following attributes:

· String Name

· String moves[6]: The actual moves (i.e. e4, e5, f4 or e4, e5, Nf3, Bb5) Note that some slots in the array can be empty if there are fewer than six moves in an opening

· String Official number of times opening has been played in tournaments (the string datatype is used as the values can be larger than the int data type allows)

· Double Percentage of White’s victory in this opening

· Double Percentage of Draw in this opening

· Double Percentage of Black’s victory in this opening

Game must have the following attributes:

· Char outcome – specifies the outcome of the game (B for Black winning, D for draw, W for white winning.

· int numMoves – specifies the number of moves in the game

· String array Moves

You have been provided with skeleton code for the tasks below. The functions are:

GetString: To retrieve a filename from the user

GetNumOpenings: return number of openings from file

Menu: function that based on user input, either prints openings, detects an opening given a game file, or exits.

Task 1

A. Create the two ADTs. You must include accessor functions, mutator functions, constructors. Depending on your implementation you might also need a user-defined destructor.

B. Then implement the function ReadOpenings, which must read a list of openings from the file “openings.txt” and store them in an array of type Opening.

Task 2

Implement the function PrintOpenings. The expected output is illustrated in Figure 2.

Figure 2

The format of the file can be seen in Figure 3.

Figure 3

Note: You can read more about the notation used to represent a move at

https://en.wikipedia.org/wiki/Chess_notation

Task 3

You must successfully load the contents of a game file to the Game ADT’s member variables.

You have two options:

1. Create a member function of the Game ADT to read the moves of a game, and then store them in the ADTs corresponding array

2. Load the game’s moves to the ADT’s array, by utilizing the constructor. To do so, you can pass the file’s name as a parameter to a user-defined constructor.

Task 4

Implement the function DetectOpening. This function must prompt for a game’s filename to be inserted, so that a game’s moves are available. Then the game’s moves must be compared against the known openings. If an opening is detected, you must print it to the screen along with the win percentages (white win, draw, black win) in the following manner:

Output

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Topnotch Essay only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided byTopnotch Essay are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Topnotch Essay is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Topnotch Essay, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.