Download presentation
Presentation is loading. Please wait.
1
6/4/01 Figure 1.1 Translating a high-level program High-level program Processor ABC program (executable) Compiler
2
6/4/01 Figure 1.2 Compiling and executing a Java program Java Source Code JVM Byte code Compiler Interpreter for Processor 1 Interpreter for Processor 2
3
6/4/01 Figure 1.4 An HTML file for the applet of Example 1.2
4
6/4/01 Get the ingredients. Get the cookware needed. Crack the eggs into a bowl. Add salt. Beat the eggs. Melt some butter in the frying pan. Pour the eggs into the frying pan. Turn the eggs over. Add the cheese, folding the eggs over. Serve the omelet. Clean up. Figure 1.9 The “program” for preparing an omelet
5
6/4/01 A First Look At Everything Art’s bank has two customers John Venn with PIN 123123123 Mabel Venn with PIN 456456456 Press the Start button to start. The ATM prompts each step with a message. Enter one of the two user names to begin transactions. Hit the Enter key when done. No new accounts or users can be created. Press the Finish button when the current user is done. Press the Start button to enter another user name. Figure 1.12 The HTML file used to run Example 1.5
6
6/4/01
7
The customer orders a burger, soda, and fries from the waiter. The waiter asks the cook to make a burger. The waiter serves the soda to the customer. The waiter asks the cook to make the fries. The cook gives the waiter the burger to serve. The cook gives the waiter the fries to serve. The waiter asks the customer to pay. Figure 1.15 A scenario for a fast food order
8
6/4/01 Customer Waiter Cook State money cash burgers and fries Responsibilities place an order take an order make burgers pay serve an item make fries Figure 1.16 State and responsibilities for Customer, Waiter, and Cook
9
6/4/01 placeOrder takeOrder makeBurger pay serve makeFries A customer A waiter A cook Figure 1.17 Objects showing only available services
10
6/4/01 Figure 1.18 Scenario for a successful deposit The user asks the teller to accept an ATM card. The teller asks the user to enter a PIN. The user asks the teller to accept a PIN. The teller asks the user to select a transaction type. The user asks the teller to accept a deposit. The teller asks the user to select an account type. The user asks the teller to accept a savings account type. The teller asks the bank to find the account of the chosen type for the user with the specified PIN. The bank gives the teller a reference to the account. The teller asks the user to specify an amount. The user asks the teller to accept an amount. The teller asks the account to deposit the specified amount. The teller asks the user to select another transaction. …
11
6/4/01 Accept an ATM card Accept a PIN Accept a transaction type Accept an account type Accept an amount Accept an account Teller Deposit an amountBankAccount Find a specified accountBank Specify a PIN Select a transaction type Select an account type Specify an amount User Figure 1.19 Responsibilities derived from the scenario of Figure 5.14
12
6/4/01 Figure 1.20 Implementing BankAccount state and behavior balance A decimal value representing the dollar amount of the current balance for that account. deposit an amount Add the amount to the current balance. withdraw an amount It the amount is not greater than the current balance, subtract the amount from the current balance. getBalance Get the current balance.
13
6/4/01 Figure 1.21 The BankAccount class BankAccount balance getBalance deposit withdraw
14
6/4/01 Figure 1.22 Two BankAccount objects myAccount:BankAccount balance = 24.50 getBalance deposit withdraw yourAccount:BankAccount balance = 142.11 getBalance deposit withdraw
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.