ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.

Slides:



Advertisements
Similar presentations
Chapter 2 Part B CISS 241. Take a few moments and work with another student to develop an algorithm for a program that will add two whole numbers (integers)
Advertisements

Lecture 2 Introduction to C Programming
CS 6301 Lecture 2: First Program1. CS Topics of this lecture Introduce first program  Explore inputs and outputs of a program Arithmetic using.
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 1 – Introduction to Computers and C++ Programming Outline 1.6 Machine Languages, Assembly Languages,
Introduction Kingdom of Saudi Arabia Shaqra University
Chapter 12 ATM Case Study, Part 1: Object-Oriented Design with the UML
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline History of C and C++ C++ Standard Library Object Technology Basics.
 2008 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
 2006 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
Three types of computer languages
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
Introduction to C++ Programming
Chapter 01: Introduction to Computer Programming
Introduction to C++ Programming
CSCI 1730 January 17 th, 2012 © by Pearson Education, Inc. All Rights Reserved.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
 2005 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 6: Continuing with output formatting.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 4: Continuing with C++ I/O Basics.
ECE 264 Object-Oriented Software Development Instructor: Dr. Michael Geiger Spring 2009 Lecture 2: Basic C++ Programs.
 2008 Pearson Education, Inc. All rights reserved. 1 CISC 1600 – Computer Science I Fall 2010 Introduction to C++ Programming Chapters 1 and 2 (Deitel.
Week 1 Algorithmization and Programming Languages.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Fall 2012 Lecture 8: File I/O; Introduction to classes.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 2: Software Design Cycle.
C++ How to Program, Late Objects Version, 7/e © by Pearson Education, Inc. All Rights Reserved.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 5: Continuing with C++ I/O Basics.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
 2008 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
Announcements Starting next week class 6-8 on Thursday Homework 1 on the web  Due January 29 – next class meeting  Homework policy No late assignments.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 9: Continuing with classes.
 2006 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
 2008 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 19: Container classes; strings.
 2006 Pearson Education, Inc. All rights reserved Introduction to C++ Programming.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 2: Software Design Cycle, Requirements Specification and.
Chapter 2 of C++ How to Program, 10/e © by Pearson Education, Inc. All Rights Reserved.
© by Pearson Education, Inc. All Rights Reserved.
Chapter 1.2 Introduction to C++ Programming
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1: Introduction to computers and C++ Programming
Introduction to C++ Programming
Introduction to C++ Programming
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Basic Elements of C++.
Introduction to C++ Programming
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
1.13 The Key Software Trend: Object Technology
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Introduction to C++ Programming
Chapter 1 – Introduction to Computers and C++ Programming
Programs written in C and C++ can run on many different computers
Capitolo 1 – Introduction C++ Programming
Introduction to C++ Programming
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics

Lecture outline Review: software design cycle Requirements specifications  Introduce UML, use case diagrams Applying design cycle to ECE 264 C++ basics 10/3/2015 ECE 264: Lecture 3 2

Software design cycle Software engineering: application of systematic approach to development, operation, and maintenance of software  Not just programming!  Lots of management involved Traditional software design cycle  Requirements engineering  Design  Programming  Integration  Delivery  Maintenance 10/3/2015 ECE 264: Lecture 3 3

Use case modeling Often preceded by “requirements gathering”  Formal name for “figure out what the clients want”  Can be done through use case modeling Formally model interactions of user(s) with system  Can then go from use cases to requirements specification Take general use cases and break down into more specific examples Formalize these steps into a specification for actions May also have to specify data to be stored, states to be kept, etc. 10/3/2015 ECE 264: Lecture 3 4

Use case diagrams Textbook example: ATM system  Assume we’re designing software for basic ATM  Given hardware description of user interface Screen to display messages Keypad for numeric input  Assume account # must be entered Cash dispenser Deposit slot  For what operations might someone want to use this ATM? 10/3/2015 ECE 264: Lecture 3 5

Use case modeling Source: 10/3/2015 ECE 264: Lecture 3 6

 2008 Pearson Education, Inc. All rights reserved. 7 Fig | Use case diagram for the ATM system from the user’s perspective.

From use case to requirements spec. What steps occur before accessing account?  Screen displays basic welcome message  Enter account #  Screen prompts user to enter PIN  Screen displays main menu if PIN correct; error otherwise (and returns to welcome) What steps should we take to withdraw money?  Choose “Withdraw money” option from menu  Screen displays amounts to be withdrawn, option to cancel, potentially option to enter different amount  Based on user input, system either proceeds with withdrawal or cancel To proceed, must check two conditions: account has enough money, and ATM has enough cash available Display error message if either condition is not true Supply money and debit account otherwise 810/3/2015 ECE 264: Lecture 3

UML diagrams Use case diagram is example of Unified Modeling Language (UML) diagram  General-purpose modeling language  Uses graphical techniques to create abstract system models Can use UML to describe  Requirements: how can someone use system?  Design: both at high and low level Overall and specific structures Overall and specific behaviors 10/3/2015 ECE 264: Lecture 3 9

UML diagrams Thirteen types of UML diagram  Model either system structure or system behavior  We’ll focus on: Use case diagram: model interactions between system and external entities in terms of system capabilities Class diagram: shows classes: building blocks of system State machine diagram: models way in which object changes state (i.e., attributes change value) Activity diagram: models actions performed and specifies order for an object Communication diagram: shows interaction between objects; focus on what interactions occur Sequence diagram: shows interaction between objects; focus on when interactions occur 10/3/2015 ECE 264: Lecture 3 10

Basic Program 1 // Adapted from figure 2.1 in text // Text-printing program #include // Allows program to // output data to the screen using std::cout; // function main begins program execution int main() { // display message cout << "Welcome to C++!\n"; return 0; // indicate program ended successfully } // end function main 10/3/2015 ECE 264: Lecture 3 11

Namespaces; using Directive The using directive instructs the compiler to use files defined within a specific namespace  Namespaces allow us to declare different scopes  Typically written right after the relevant header file(s) Example: using namespace std;  std is the name of the Standard C++ namespace  Including this line allows you to avoid specifying namespace for every identifier in your headers …  … but allows everything in the std namespace  Compromise: list namespace members actually used using std::cout; Otherwise, you’d have to write “ std::cout ” every time 10/3/2015 ECE 264: Lecture 3 12

Input/output streams C++ has three standard input/output streams  cin is the standard input (e.g., keyboard)  cout is the standard output  cerr is the standard error 10/3/2015 ECE 264: Lecture 3 13

Input/output streams (cont.) Standard output  Use the stream output operator << to direct data to cout  General Form: cout << expression << expression;  Note: An expression is a C++ constant, identifier, formula, or function call.  endl can be used to place an output character in the buffer and flush the buffer 10/3/2015 ECE 264: Lecture 3 14

15 Modifying Our First C++ Program Two examples  Print text on one line using multiple statements (Fig. 2.3) Each stream insertion resumes printing where the previous one stopped  Print text on several lines using a single statement (Fig. 2.4) Each newline escape sequence positions the cursor to the beginning of the next line Two newline characters back-to-back outputs a blank line 10/3/2015 ECE 264: Lecture 3

Modified program: two cout statements // Adapted from figure 2.3 in text // Printing a line of text with multiple statements #include // Allows program to // output data to the screen using std::cout; // function main begins program execution int main() { // display message cout << "Welcome " cout << "to C++!\n"; return 0; // indicate program ended successfully } // end function main 10/3/2015 ECE 264: Lecture 3 16

Modified program: multiple output lines 10/3/2015 ECE 264: Lecture 3 17 // Adapted from figure 2.4 in text // Printing multiple lines of text with one statement #include // Allows program to // output data to the screen using std::cout; // function main begins program execution int main() { // display message cout << "Welcome\nto\n\nC++!\n"; return 0; // indicate program ended successfully } // end function main

Another C++ Program: Adding Integers Variable  Is a location in memory where a value can be stored  Common data types (fundamental, primitive or built-in) int – for integer numbers char – for characters double – for floating point numbers  Declare variables with data type and name before use int integer1; int integer2; int sum; 10/3/2015 ECE 264: Lecture 3 18

Input streams Standard input  Use the stream input operator >> to direct keyboard input to variables  General Form: cin >> identifier >> identifier;  Input value must be compatible with identifier type 10/3/2015 ECE 264: Lecture 3 19

Basic program 2 // Adapted from figure 2.5 in text // Addition program that displays the sum of two integers. #include using std::cout; using std::cin; using std::endl; int main() { // variable declarations int number1; int number2; int sum; // prompt user for data and read into appropriate variables cout << "Enter first integer: "; cin >> number1; cout << "Enter second integer: "; cin >> number2; sum = number1 + number2; // add the numbers; store result in sum cout << "Sum is " << sum << endl; // display sum; end line return 0; // indicate that program ended successfully } // end function main 10/3/2015 ECE 264: Lecture 3 20

Final notes Next time Continue with C++ basics More examples of basic I/O Acknowledgements: this lecture borrows heavily from lecture slides provided with the following texts: Deitel & Deitel, C++ How to Program, 8 th ed. Etter & Ingber, Engineering Problem Solving with C++, 2 nd ed. 10/3/2015 ECE 264: Lecture 3 21