Fundamentals of Software Development 1Slide 1 Today’s Summary Statements: Conditionals (if-then-else)Statements: Conditionals (if-then-else) Investigated programming patterns:Investigated programming patterns: –Increment, swap, select from cases, absolute value, maximum of two Continued writing your own classes – WordGames! Especially,Continued writing your own classes – WordGames! Especially, –(Today) Part4: Writing classes that require conditionals and fields And that’s going to do it for WordGames!And that’s going to do it for WordGames! Summarized on the next few slides
Fundamentals of Software Development 1Slide 2 Conditionals The statements executed depend on a conditionThe statements executed depend on a condition –Note the basic forms and punctuation: if (condition) { statement; statement;......} if (condition) { statement; statement; } else { statement; statement;......} if (x < y) { min = x; min = x; } else { min = y; min = y;} if (naomi.winsRace()) { ++ count; ++ count;} Why are the indentations and curly braces important?
Fundamentals of Software Development 1Slide 3 Programming Patterns We saw that many problems fit a “pattern” that experienced software developers recognizeWe saw that many problems fit a “pattern” that experienced software developers recognize –And hence can easily code, from experience Today, we saw these patterns:Today, we saw these patterns: –Swap –Absolute value –Maximum of two –Select from cases –Increment Next time: Looping patterns
Fundamentals of Software Development 1Slide 4 Programming patterns – summary temp = x; x = y; y = temp; if (y < 0) { x = -y; } else { x = y; } if (x > y) { z = x; } else { z = y; } swap absolute value maximum of two if (x >= 90) { z = ‘A’; } else if (x >= 80) { z = ‘B’; } else if (x >= 70) { z = ‘C’; } else if (x >= 60) { z = ‘D’; } else { z = ‘F’; } x = x + 1; Increment (for counting) Select from cases Keep these patterns in mind, to help you with similar problems that you encounter
Fundamentals of Software Development 1Slide 5 What’s Ahead? Before the next session:Before the next session: –Do Homework 9 (no late homework!) Including the reading and the associated online quiz on Ch 6Including the reading and the associated online quiz on Ch 6 Turn in the finished WordGames after completing Part 4Turn in the finished WordGames after completing Part 4 –Next session: Hello World, part 1!Hello World, part 1! Next week – Exam 1:Next week – Exam 1: –Review session Tuesday night, Mar :00 – 9:00 pm O157 –Exam Wednesday night, Mar 30 - CSSE (Steve) – O157 CSSE (Salman) – O169 Reminder: Find the homework assignment from the Schedule page of the CSSE 120 Angel site angel.rose-hulman.edu Our usual suggestion: Routinely do your homework in F-217 (CSSE lab). A student assistant is there every Sunday through Thursday evening, 7 pm to 9 pm, so you can get immediate answers to any questions you might have.