Chapter 11 Programming Projects


[Page 602 (continued)]

  1. Son of Deep Blue. Write a program that plays a game of tic-tac-toe in which a person competes with the computer. The game should be played in a control array of nine text boxes. See Figure 11.11. After the user moves by placing an X in a text box, the program should determine the location for the O. The program should use a tic-tac-toe object that raises events when a player moves and when the game is over. The outcome of the game should be announced in a message dialog box.

    Figure 11.11. Tic-Tac-Toe.

  2. Bank Account.Write a program to maintain a person's Savings and Checking accounts. The program should keep track of and display the balances in both accounts, and maintain a list of transactions (deposits, withdrawals, fund transfers, and check clearings) separately for each account. The two lists of transactions should be stored in sequential files so that they will persist between program sessions.


    [Page 603]

    Consider the form in Figure 11.12. The two dropdown combo boxes should each contain the items Checking and Savings. Each of the four group boxes corresponds to a type of transaction. (When Savings is selected in the Account combo box, the Check group box should disappear.) The user makes a transaction by typing data into the text boxes of a group box and pressing the button. The items appearing in the Transactions list box should correspond to the type of account that has been selected. The caption of the second label in the Transfer group box should toggle between "to Checking" and "to Savings" depending on the item selected in the "Transfer from" combo box. If a transaction cannot be carried out, a message (such as "Insufficient funds") should be displayed.

    Figure 11.12. Bank accounts.

    The program should use two classes, Transaction and Account. The class Transaction should have properties for transaction name, amount, date, and whether it is a credit (deposit) or debit (withdrawal/check).

    The class Account, which will have both a checking account and a savings account as instances, should use an array of Transaction objects. In addition, it should have properties for name (Checking or Savings) and balance. It should have methods to carry out a transaction (if possible), to display the list of transactions, and to load and retrieve the set of transactions into or from a sequential file. The events InsufficientFunds and TransactionCommitted should be triggered at appropriate times. A technique for obtaining a string containing today's date can be found in the frmAccount_Load procedure of the case study "Recording Checks and Deposits" in Section 8.3.

    Hint: In order for an Account object to display a list of transactions, a list box should be passed to a method as an argument. The method might be declared with Sub EnumerateTransactions(ByVal lb As ListBox).


  3. [Page 604]
  4. Write a program for the game BlackJack. See Figure 11.13. The program should use a Blackjack class (Blackjack) that contains a member variable of the type DeckOfCards presented in Example 3 of Section 11.2.

Figure 11.13. Sample output for Programming Project 3.





An Introduction to Programming Using Visual Basic 2005
Introduction to Programming Using Visual Basic 2005, An (6th Edition)
ISBN: 0130306541
EAN: 2147483647
Year: 2006
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net