Em Andamento

4 Short C++ Classes/Programs

Four classes/functions listed in the deliverables section.

## Deliverables

1. Create a class called Board for use in playing the game tic-tac-toe. Recall that the game is played on a 3 x 3 board, where every square is either empty, or contains an “X?? or an “O.?? The game is won when there are three X’s or O’s in a straight line, either in the same column, the same row, or the two diagonals. The game is a stalemate when the board has no empty squares but neither X nor O has won. The following includes references to an enumerated type Player, defined as: enum Player {X, O, empty}; Your class should have the following public methods: Board: (constructor) This initializes the board, which means it sets all the positions to empty and does all else necessary to make the board ready for use. void Place(P, Column, Row): A procedure that takes a Player P and sets the Column and Row of the board to be Player P. int Win(P): A function that returns 1 if Player P has won the game, and 0 otherwise. int Stalemate(): A function that returns 1 if the board represents a game in stalemate, and 0 otherwise. You do not have to write a complete program that plays the game. However, you should include a short program that adequately tests all the operations of the class. 2. Write recursive procedures (void functions) that perform insertion and retrieval operations on a sorted linked list of integers. Use these procedures to write a program that inputs a series of integers, inserting them into a list until 0 is entered. Then a second series of integers is input, until 0 is entered, and the position of each integer in the list is displayed. Example: Enter numbers to be inserted (0 to end): 34 23 1 45 7 0 The list is: 1 7 23 34 45 Enter numbers to be retrieved (0 to end): 23 8 45 0 23 is at position 3 8 is not in the list 45 is at position 5 Note that the program should be able to handle requests to retrieve items that are not in the list. 3. Expand the listClass provided in the attachment. Set the listItemType to int. Add methods to find the smallest number in the list, the largest number in the list, and the average of the list. Write a short program that tests your methods. 4. An integer can be represented by a linked list with one digit in each node. The least significant digit in this representation is in the first node of the list. This allows for integers of virtually any size. The nodes are of the following type: struct digit { int Value; // a digit value, 0-9 digit* Next; }; typedef digit* number; Develop an ADT with the following operations for unlimited-digit numbers. In the following descriptions, number refers to a linked list of digits, and M, N and O are all numbers. Increment: A method that increases the value of a number by 1. Sample usage: [url removed, login to view](); Note that you cannot necessarily just change the last digit of the number; adding 1 to 1999, for example, requires changing all four digits to get 2000, and adding 1 to 9 requires making a new digit to get 10. Hint: You should allow for three possibilities in your function regarding the initial value for N. a. N is NULL b. N is not NULL, and the value in the first node is 0..8 c. N is not NULL, and the value in the first node is 9 Copy: A method that copies one number to another. Note that you cannot just copy one pointer to another ??" you must create copies of each node in the original. Sample usage: [url removed, login to view](M); Sum: A method that takes two numbers and sums them. Sample usage: [url removed, login to view](M); (adds M to N). Another possibility: [url removed, login to view](M,O); DisplayNumber: A method that displays its argument (a number) in standard (most significant digit first) form. Sample usage: [url removed, login to view](); Your ADT should be a C++ class, with all functions and data declared in the appropriate sections. You may use recursion as you wish. Include a short program that adequately tests all the procedures in your ADT.

## Platform


Habilidades: Programação C, Engenharia, MySQL, PHP, Arquitetura de software, Teste de Software

Ver mais: write a recursive function, when to use recursion, struct c programming, sorted data set, representation of integers, recursive programs, recursive programming example, recursive programming, recursive program example, recursive function example, recursion programming, recursion means, recursion in programming, recursion function, programs for php programming, programming recursion, programming classes, programming board game, pointer programming, node programming, linked int, largest number, int size c, integers form 1, input board game

Acerca do Empregador:
( 6 comentários ) United States

ID do Projeto: #2961415

Premiar a:


See private message.

$22.1 USD em 7 dias
(94 Avaliações)

6 freelancers estão ofertando em média $32 para este trabalho


See private message.

$29.75 USD in 7 dias
(54 Comentários)

See private message.

$28.05 USD in 7 dias
(34 Comentários)

See private message.

$34 USD in 7 dias
(10 Comentários)

See private message.

$34 USD in 7 dias
(9 Comentários)

See private message.

$42.5 USD in 7 dias
(7 Comentários)