Chapter 8 Object-Based Programming 341 a) Incrementing into (Hp web site)
Chapter 8 Object-Based Programming 341 a) Incrementing into the next month. b) Incrementing into the next year. 8.5 Create a class TicTacToe that will enable you to write a complete program to play the game of Tic-Tac-Toe. The class contains as private data a 3-by-3 double array of characters. The constructor should initialize the empty board to all spaces, ‘ ‘. Allow two players. Wherever the first player moves, place an ‘X’ in the specified square; place an ‘O’ wherever the second player moves. Each move must be to an empty square. After each move, determine whether the game has been won or if the game is a draw via a GameStatus method. [Hint: use an enumeration constant to return the following statuses: WIN, DRAW, CONTINUE.] Write Windows Application TicTac- ToeTest to test your class. If you feel ambitious, modify your program so that the computer makes the moves for one of the players automatically. Also, allow the player to specify whether he or she wants to go first or second. If you feel exceptionally ambitious, develop a program that will play three-dimensional Tic-Tac-Toe on a 4-by-4-by-4 board [Note: This is a challenging project that could take many weeks of effort!] 8.6 Create a Date class with the following capabilities: a) Output the date in multiple formats such as MM/DD/YYYY June 14, 2001 DDD YYYY b) Use overloaded constructors to create Date objects initialized with dates of the formats in part a). 8.7 Create class SavingsAccount. Use static variable annualInterestRate to store the interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalanceby annualInterestRatedivided by 12; this interest should be added to savingsBalance. Provide a static method ModifyInterestRate that sets the annualInterestRate to a new value. Write a driver program to test class SavingsAccount. Instantiate two savingsAccount objects, saver1and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest and print the new balances for each of the savers. Then set the annualInterestRate to 5% and calculate the next month s interest and print the new balances for each of the savers. 8.8 Write a console application that implements a Square shape. Class Square should contain an instance property Side that has get and set accessors for private data. Provide two constructors: one that takes no arguments and another that takes a side length as a value. Write an application class that tests class Square s functionality.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.