Outline Software Development Activities

Slides:



Advertisements
Similar presentations
Flow of Control Usually the order of statement execution through a method is linear: one after another flow of control: the order statements are executed.
Advertisements

1 Control Structures (and user input). 2 Flow of Control The order statements are executed is called flow of control By default, statements in a method.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Flow of Control (1) : Logic Clark Savage Turner, J.D., Ph.D. Some lecture slides have been adapted from those developed.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
Aalborg Media Lab 23-Jun-15 Software Design Lecture 6 “Conditionals and Loops”
ECE122 L7: Conditional Statements February 20, 2007 ECE 122 Engineering Problem Solving with Java Lecture 7 Conditional Statements.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Program Statements Selim Aksoy Bilkent University Department of Computer Engineering
Boolean Expressions and If Flow of Control / Conditional Statements The if Statement Logical Operators The else Clause Block statements Nested if statements.
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/33 Conditionals and Loops Now we will examine programming statements.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Flow of Control Java Programming Mrs. C. Furman January 5, 2009.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Chapter 3: Program Statements
Programming in Java (COP 2250) Lecture 11 Chengyong Yang Fall, 2005.
© 2006 Pearson Education 1 Obj: to use compound Boolean statements HW: p.184 True/False #1 – 6 (skip 3)  Do Now: 1.Test your “Charge Account Statement”
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Copyright © 2012 Pearson Education, Inc. Chapter 6 More Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John.
Copyright © 2012 Pearson Education, Inc. Lab 8: IF statement …. Conditionals and Loops.
1 Chapter 3 Selections. 2 Outline 1. Flow of Control 2. Conditional Statements 3. The if Statement 4. The if-else Statement 5. The Conditional operator.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 Interactive Applications (CLI) and Math Interactive Applications Command Line Interfaces The Math Class Flow of Control / Conditional Statements The.
Chapter 6. else-if & switch Copyright © 2012 Pearson Education, Inc.
5-1 Chapter 5: Conditionals and Loops Topics: –Boolean expressions –Conditional statements –Increment and Decrement Operators (Chapter 2.4) –Repetition.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Topics Logical Operators (Chapter 5) Comparing Data (Chapter 5) The conditional operator The switch Statement The for loop Nested Loops.
Flow of Control Unless indicated otherwise, the order of statement execution through a method is linear: one after the other in the order they are written.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 Object-Oriented Design Now we can extend our discussion of the design of classes and objects Chapter 6 focuses on: software development activities determining.
Control statements Mostafa Abdallah
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
1 b Boolean expressions b truth tables b conditional operator b switch statement b repetition statements: whilewhile do/whiledo/while forfor Lecture 3.
© 2004 Pearson Addison-Wesley. All rights reserved October 31, 2007 Static Class Members ComS 207: Programming I (in Java) Iowa State University, FALL.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
CprE 185: Intro to Problem Solving (using C)
Chapter 3: Program Statements
Chapter 5 Conditionals and Loops
Chapter 6 More Conditionals and Loops
Operator Precedence Operators Precedence Parentheses () unary
Boolean Expressions and If
Boolean Expressions & the ‘if’ Statement
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
The switch Statement The switch statement provides another way to decide which statement to execute next The switch statement evaluates an expression,
Chapter 3: Program Statements
Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one after another Some programming statements.
Chapter 6 More Conditionals and Loops
Logical Operators & Truth Tables.
Chapter 3: Program Statements
Chapter 3: Program Statements
Outline Boolean Expressions The if Statement Comparing Data
Chapter 3: Program Statements
Chapter 3: Program Statements
Static Class Members March 29, 2006 ComS 207: Programming I (in Java)
Logic of an if statement
Chapter 3: Program Statements
CSC 1051 – Data Structures and Algorithms I
CprE 185: Intro to Problem Solving (using C)
Outline Boolean Expressions The if Statement Comparing Data
Chapter 3: Program Statements
Conditionals and Loops
Boolean Expressions & the ‘if’ Statement
CprE 185: Intro to Problem Solving (using C)
3.0 - Design A software design specifies how a program will accomplish its requirements A design includes one or more algorithms to accomplish its goal.
Presentation transcript:

Outline Software Development Activities Identifying Classes and Objects Static Variables and Methods Class Relationships Interfaces Enumerated Types Revisited Method Design Testing GUI Design and Layout Copyright © 2012 Pearson Education, Inc.

Program Development The creation of software involves four basic activities: establishing the requirements creating a design implementing the code testing the implementation These activities are not strictly linear – they overlap and interact Copyright © 2012 Pearson Education, Inc.

Requirements Software requirements specify the tasks that a program must accomplish what to do, not how to do it Often an initial set of requirements is provided, but they should be critiqued and expanded It is difficult to establish detailed, unambiguous, and complete requirements Careful attention to the requirements can save significant time and expense in the overall project Copyright © 2012 Pearson Education, Inc.

Design A software design specifies how a program will accomplish its requirements A software design specifies how the solution can be broken down into manageable pieces and what each piece will do An object-oriented design determines which classes and objects are needed, and specifies how they will interact Low level design details include how individual methods will accomplish their tasks Copyright © 2012 Pearson Education, Inc.

Implementation Implementation is the process of translating a design into source code Novice programmers often think that writing code is the heart of software development, but actually it should be the least creative step Almost all important decisions are made during requirements and design stages Implementation should focus on coding details, including style guidelines and documentation Copyright © 2012 Pearson Education, Inc.

Testing Testing attempts to ensure that the program will solve the intended problem under all the constraints specified in the requirements A program should be thoroughly tested with the goal of finding errors Debugging is the process of determining the cause of a problem and fixing it We revisit the details of the testing process later in this chapter Copyright © 2012 Pearson Education, Inc.

Outline Boolean Expressions The if Statement Comparing Data The while Statement Iterators The ArrayList Class Determining Event Sources Check Boxes and Radio Buttons Copyright © 2012 Pearson Education, Inc.

Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one after another Some programming statements allow us to make decisions and perform repetitions These decisions are based on boolean expressions (also called conditions) that evaluate to true or false The order of statement execution is called the flow of control Copyright © 2012 Pearson Education, Inc.

Conditional Statements A conditional statement lets us choose which statement will be executed next They are sometimes called selection statements Conditional statements give us the power to make basic decisions The Java conditional statements are the: if and if-else statement switch statement We'll explore the switch statement in Chapter 6 Copyright © 2012 Pearson Education, Inc.

Boolean Expressions A condition often uses one of Java's equality operators or relational operators, which all return boolean results: == equal to != not equal to < less than > greater than <= less than or equal to >= greater than or equal to Note the difference between the equality operator (==) and the assignment operator (=) Copyright © 2012 Pearson Education, Inc.

Boolean Expressions An if statement with its boolean condition: if (sum > MAX) delta = sum – MAX; First, the condition is evaluated: the value of sum is either greater than the value of MAX, or it is not If the condition is true, the assignment statement is executed; if it isn't, it is skipped See Age.java Copyright © 2012 Pearson Education, Inc.

//******************************************************************** // Age.java Author: Lewis/Loftus // // Demonstrates the use of an if statement. import java.util.Scanner; public class Age { //----------------------------------------------------------------- // Reads the user's age and prints comments accordingly. public static void main (String[] args) final int MINOR = 21; Scanner scan = new Scanner (System.in); System.out.print ("Enter your age: "); int age = scan.nextInt(); continue Copyright © 2012 Pearson Education, Inc.

System.out.println ("You entered: " + age); if (age < MINOR) continue System.out.println ("You entered: " + age); if (age < MINOR) System.out.println ("Youth is a wonderful thing. Enjoy."); System.out.println ("Age is a state of mind."); } Copyright © 2012 Pearson Education, Inc.

Sample Run Another Sample Run Enter your age: 47 You entered: 47 Age is a state of mind. continue System.out.println ("You entered: " + age); if (age < MINOR) System.out.println ("Youth is a wonderful thing. Enjoy."); System.out.println ("Age is a state of mind."); } Another Sample Run Enter your age: 12 You entered: 12 Youth is a wonderful thing. Enjoy. Age is a state of mind. Copyright © 2012 Pearson Education, Inc.

Logical Operators Boolean expressions can also use the following logical operators: ! Logical NOT && Logical AND || Logical OR They all take boolean operands and produce boolean results Logical NOT is a unary operator (it operates on one operand) Logical AND and logical OR are binary operators (each operates on two operands) Copyright © 2012 Pearson Education, Inc.

Logical NOT The logical NOT operation is also called logical negation or logical complement If some boolean condition a is true, then !a is false; if a is false, then !a is true Logical expressions can be shown using a truth table: a !a true false Copyright © 2012 Pearson Education, Inc.

Logical AND and Logical OR The logical AND expression a && b is true if both a and b are true, and false otherwise The logical OR expression a || b is true if a or b or both are true, and false otherwise Copyright © 2012 Pearson Education, Inc.

Logical AND and Logical OR A truth table shows all possible true-false combinations of the terms Since && and || each have two operands, there are four possible combinations of conditions a and b a b a && b a || b true false Copyright © 2012 Pearson Education, Inc.

Logical Operators Expressions that use logical operators can form complex conditions if (total < MAX+5 && !found) System.out.println ("Processing…"); All logical operators have lower precedence than the relational operators The ! operator has higher precedence than && and || Copyright © 2012 Pearson Education, Inc.

Boolean Expressions Specific expressions can be evaluated using truth tables total < MAX found !found total < MAX && !found false true Copyright © 2012 Pearson Education, Inc.

Short-Circuited Operators The processing of && and || is “short-circuited” If the left operand is sufficient to determine the result, the right operand is not evaluated if (count != 0 && total/count > MAX) System.out.println ("Testing."); This type of processing should be used carefully Copyright © 2012 Pearson Education, Inc.