+ All Categories
Home > Documents > Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Date post: 17-Mar-2016
Category:
Upload: kaveri
View: 29 times
Download: 2 times
Share this document with a friend
Description:
Department of Computer and Information Science, School of Science, IUPUI. Object Oriented Programming using Java - OOD to OOP: ATM Case Study. Dale Roberts, Lecturer Computer Science, IUPUI E-mail: [email protected]. Starting to Program the Classes of the ATM System. Visibility - PowerPoint PPT Presentation
14
Dale Roberts Object Oriented Programming using Object Oriented Programming using Java Java - OOD to OOP: ATM Case Study - OOD to OOP: ATM Case Study Dale Roberts, Lecturer Computer Science, IUPUI E-mail: [email protected] Department of Computer and Information Science, School of Science, IUPUI
Transcript
Page 1: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

Object Oriented Programming using JavaObject Oriented Programming using Java

- OOD to OOP: ATM Case Study- OOD to OOP: ATM Case Study

Dale Roberts, LecturerComputer Science, IUPUIE-mail: [email protected]

Department of Computer and Information Science,School of Science, IUPUI

Page 2: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts2

Starting to Program the Classes of the ATM SystemStarting to Program the Classes of the ATM System

VisibilityVisibilityAttributes normally should be private, methods Attributes normally should be private, methods invoked by clients should be publicinvoked by clients should be publicVisibility markers in UMLVisibility markers in UML

A plus sign (+) indicates public visibilityA plus sign (+) indicates public visibilityA minus sign (-) indicates private visibilityA minus sign (-) indicates private visibility

NavigabilityNavigabilityNavigability arrows indicate in which direction an Navigability arrows indicate in which direction an association can be traversedassociation can be traversedBidirectional navigabilityBidirectional navigability

Associations with navigability arrows at both ends or no Associations with navigability arrows at both ends or no navigability arrows at all can be traversed in either directionnavigability arrows at all can be traversed in either direction

Page 3: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts3

Fig. 8.24 Fig. 8.24 | Class diagram with visibility markers.| Class diagram with visibility markers.

Page 4: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts4

Fig. 8.25 Fig. 8.25 | Class diagram with navigability arrows. | Class diagram with navigability arrows.

Page 5: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts5

Starting to Program the Classes of the ATM System (Cont.)Starting to Program the Classes of the ATM System (Cont.)

Implementing the ATM system from its UML Implementing the ATM system from its UML design (for each class)design (for each class)

Declare a Declare a publicpublic class with the name in the first class with the name in the first compartment and an empty no-argument constructorcompartment and an empty no-argument constructorDeclare instance variables based on attributes in the Declare instance variables based on attributes in the second compartmentsecond compartmentDeclare references to other objects based on Declare references to other objects based on associations described in the class diagramassociations described in the class diagramDeclare the shells of the methods based on the Declare the shells of the methods based on the operations in the third compartmentoperations in the third compartment

Use the return type Use the return type voidvoid if no return type has been specified if no return type has been specified

Page 6: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts6

Fig. 8.24 Fig. 8.24 | Class diagram with visibility markers.| Class diagram with visibility markers.

Page 7: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

7OutlineOutline

1 // Class Withdrawal represents an ATM withdrawal transaction

2 public class Withdrawal

3 {

4 // no-argument constructor

5 public Withdrawal()

6 {

7 } // end no-argument Withdrawal constructor

8 } // end class Withdrawal

withdrawal.java

Class for Withdrawal

Empty no-argument constructor

Page 8: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts8

Fig. 8.24 Fig. 8.24 | Class diagram with visibility markers.| Class diagram with visibility markers.

Page 9: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

9OutlineOutline

1 // Class Withdrawal represents an ATM withdrawal transaction

2 public class Withdrawal

3 {

4 // attributes

5 private int accountNumber; // account to withdraw funds from

6 private double amount; // amount to withdraw

7

8 // no-argument constructor

9 public Withdrawal()

10 {

11 } // end no-argument Withdrawal constructor

12 } // end class Withdrawal

withdrawal.java

Declare instance variables

Page 10: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts10

Fig. 8.25 Fig. 8.25 | Class diagram with navigability arrows. | Class diagram with navigability arrows.

Page 11: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

11OutlineOutline

1 // Class Withdrawal represents an ATM withdrawal transaction 2 public class Withdrawal 3 { 4 // attributes 5 private int accountNumber; // account to withdraw funds from 6 private double amount; // amount to withdraw 7 8 // references to associated objects 9 private Screen screen; // ATM’s screen 10 private Keypad keypad; // ATM’s keypad 11 private CashDispenser cashDispenser; // ATM’s cash dispenser 12 private BankDatabase bankDatabase; // account info database 13 14 // no-argument constructor 15 public Withdrawal() 16 { 17 } // end no-argument Withdrawal constructor 18 } // end class Withdrawal

withdrawal.java

Declare references to other objects

Page 12: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts12

Fig. 8.24 Fig. 8.24 | Class diagram with visibility markers.| Class diagram with visibility markers.

Page 13: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

13OutlineOutline

1 // Class Withdrawal represents an ATM withdrawal transaction 2 public class Withdrawal 3 { 4 // attributes 5 private int accountNumber; // account to withdraw funds from 6 private double amount; // amount to withdraw 7 8 // references to associated objects 9 private Screen screen; // ATM’s screen 10 private Keypad keypad; // ATM’s keypad 11 private CashDispenser cashDispenser; // ATM’s cash dispenser 12 private BankDatabase bankDatabase; // account info database 13 14 // no-argument constructor 15 public Withdrawal() 16 { 17 } // end no-argument Withdrawal constructor 18 19 // operations 20 public void execute() 21 { 22 } // end method execute 23 } // end class Withdrawal

withdrawal.java

Declare shell of a method with return type void

Page 14: Object Oriented Programming using Java - OOD to OOP: ATM Case Study

Dale Roberts

AcknowledgementsAcknowledgementsDeitel, Java How to Program


Recommended