19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Remove method. The number of objects in a collection is determined with the<br />

Count property <strong>and</strong> object is returned by the Item method using either a number<br />

or a key.<br />

7. Events are declared in the general declarations section of class module with a<br />

statement of the form Public Event UserDefinedEvent (arg1, arg2,<br />

...) <strong>and</strong> triggered with a RaiseEvent statement. In the form code, the declaration<br />

statement for an object, must include the keyword WithEvents in order for<br />

the events coming from the object to be processed.<br />

8. Objects interact through use <strong>and</strong> containment.<br />

PROGRAMMING PROJECTS<br />

1. Son of Deep Blue. Write a program that plays a game of tic-tac-toe in which a<br />

person competes with the computer. The game should be played in a control<br />

array of nine labels. See Figure 12-3. After the user moves by placing an X in<br />

a label, the program should determine the location for the O. The program<br />

should use a tic-tac-toe object that raises events when a player moves <strong>and</strong> when<br />

the game is over. The outcome of the game should be announced in a message<br />

box.<br />

FIGURE 12-3 Tic-Tac-Toe<br />

2. Bank Account. Write a program to maintain a person’s Savings <strong>and</strong> Checking<br />

accounts. The program should keep track of <strong>and</strong> display the balances in both<br />

accounts, <strong>and</strong> maintain a list of transactions (deposits, withdrawals, fund transfers,<br />

<strong>and</strong> check clearings) separately for each account. The two lists of transactions<br />

should be stored in sequential files so that they will persist between<br />

program sessions.<br />

Consider the form in Figure 12-4. The two drop-down combo boxes should each<br />

contain the items Checking <strong>and</strong> Savings. Each of the four frames corresponds<br />

to a type of transaction. (When Savings is selected in the Account combo box,<br />

the Check frame should disappear.) The user makes a transaction by typing data<br />

into the text boxes of a frame <strong>and</strong> pressing the comm<strong>and</strong> button. The items<br />

appearing in the transactions list box should correspond to the type of account<br />

that has been selected. The caption of the second label in the Transfer frame<br />

should toggle between “to Checking” <strong>and</strong> “to Savings” depending on the item<br />

selected in the “Transfer from” combo box. If a transaction cannot be carried<br />

out, a message (such as “Insufficient funds”) should be displayed.<br />

<strong>Programming</strong> Projects 381

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!