Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18COSC 181 – Foundations of Computer ProgrammingClass 5ATM Requirements Spec.Introduce you to O.O. programming with this exampleThreaded through the next several chaptersFirst Step - Gather RequirementsATM – allow users to perform basic bankingOne account per userUsers should be able toView balanceWithdraw cashDeposit fundsHardwareScreen/Keypad/Cash Dispenser/Deposit SlotKey Elements - Things learn from talking to the bank managersATM begins each day stocked with 500 $20 bills.Each user is asked to type in his own account id.All output from ATM occurs on screen.Bank wants you to write the softwareneed not worry about hardware interfacesoftware first runs on your computermonitor simulates the ATM screenkeyboard simulates ATM keypadWhat are some activities performed at an ATM?User Experience ModelA.K.A - Use CasesStandard UML (Unified Modeling Language) Diagram. We’ll talk about other UML diagrams at the end of today’s slides.The User Experience1. Screen displays a welcome message and prompts for the account number2. User enters 5 digit account number3. ATM asks user to enter PIN4. User enters 5 digit PIN, using the keypad5. ATM checks Acct#/PIN comboif valid : ATM displays main menuif invalid: ATM displays an appropriate messageWhat are the items that should be on the main menu?Main MenuMain Menu: 1 - View my balance 2 - Withdraw cash 3 - Deposit funds 4 - ExitEnter a choice1 - View My BalanceATM displays a screen with the user’s balance2 - Withdraw Cash (Menu)Withdrawal options:1 - $20 4 - $1002 - $40 5 - $2003 - $60 6 - Cancel transactionChoose a withdrawal option (1-6):System States1. Withdrawal amount greater than balanceerror message : return to previous menu2. Withdrawal amount less than balance(2 cases)if enough money in dispenserdebit account and dispense moneydisplay message reminding user to take moneyif not enough money in dispenserdisplay error and return to previous menu3 - Deposit FundsEnter a deposit amount (0 to cancel): (Again – 2 Cases to Consider)3. Deposit amount enteredATM prompts user to insert envelopeonce envelope inserted ATM credits balance4. 0 enteredATM returns to previous menuDesigning the System1. Use Case Diagramsmodels how the various users will use the system2. Class Diagrams (Chapter 3)classes define objectseach noun described in requirements could be a class3. State Machine Diagrams (Chapter 3)state - value of all object attributesmodels how the classes will interactContinued1. Activity Diagrams (Chapter 5)models an objects workflow2. Communication Diagrams (Chapter 7)models interaction amongst objects3. Sequence Diagrams (Chapter 7)models when interactions occur between objectsGradeBook ClassReferencing Fig 3.1Defining a classTelling the compiler what member functions and data members belong to the classMember FunctiondisplayMessage()Displays a message on the screenDefining the GradeBook ClassLine 9 – 17//GradeBook class definitionclass GradeBook{public://function that displays a messagevoid displayMessage(){cout << “Welcome to the Grade Book!” << endl;}};Classes have identifiers, just like variables  Follow same rulesBy convention, class identifiers begin with a capital letter.Uses “camel case” notation  FirstSecondEasier to readEvery class is enclosed in { }, with a ; after the closing bracketpublic: indicates that the affected part of the class (members and functions) are accessible by functions outside the class (i.e. – main())Functionsvoid displayMessage() is a functionmain() is also a functionUnlike main(), displayMessage() is not called automaticallyFunctions perform tasks and might return valuesWhat about displayMessage() ?Functions (con’t) void displayMessage()void – return type displayMessage – function name (identifier)By convention, first letter lower-case() – indicates that this is a functionEmpty parenthesis indicate that no additional data is needed for the function to perform its task{ } – all statements in a function appear between braces (no semicolon)Using the GradeBook class in a programWant to “call” displayMessage() to display the message on the screenCan’t call a member function until you create an instance of the classLines 22 and 23 in Fig 3.1GradeBook myGradeBook;“GradeBook” type is defined because we included the GradeBook class in the codemyGradeBook.displayMessage();“dot operator”UML: Class DiagramsClasses represented as a rectangle with 3 compartmentsClasses NameClasses Attributes C++ Data Members (more on this later)Classes


View Full Document

UVa-Wise COSC 181 - Foundations of Computer Programming

Download Foundations of Computer Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Foundations of Computer Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Foundations of Computer Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?