A provocative question embedded in a friend-compatability checker created by a Java student in the Spring of 2018

Might we be friends? Decision logic exercise

Project specifications

Start Here: Jump to a section

wb_incandescentProject steps and code samples
wb_incandescentSample friend flow charts
check_boxCode sample: gathering integer input
bookCode sample: gathering text input

Project steps and code samples

  1. Flow chart on paper: Create a friend compatibility flow chart on paper like the ones shown below. Use our module guide on flow charting and if/else blocks as your reference. Remember, for our first draft, we'll only be gathering integer responses from the user. Once this works, you can work on String comparisons.
  2. Review sample code: Study the sample code with decision logic only that shows how to code up a single question with a hard-coded response
  3. Code it up: Write a draft version of your program like the previous sample in PyCharm:
  4. Test: Test your code ruthlessly! Make sure the logic works as the flow chart shows. Adjust your flow chart if you made mistakes.
  5. Comment your code sufficiently that another programmer of your level could read your code and understand its inner workings
  6. Sync: Make sure your hand-written flow chart matches how your program actually executes. Adjust one or the other to make them match.
  7. Share: Upload your code: Create a gitlab account if you don't already have one using this step-by-step guide.

Extension ideas

arrow_upward back up to contents

Sample program output and source code

When fully-baked, a sample program output can look like figure 4

Figure 4: Sample program interaction
sample program interaction

arrow_upward back up to contents

wb_incandescentSample flow charts

Legacy students have authorized the sharing of their work for the benefit of future javas at CCAC. Use their work as launchpads for yours.

Zoom in on images

On Win/Linux, Hold down control and engage your mouse's scroll ball to zoom.

Figure 1: Dogs and gamers
student flow chart samples
Notice the creator's use of the term "Break" that appears multiple times in the flow system. Break signals a termination of the decision logic, and can occur as flow of execution winds through several paths. BUT, in Java if/else, we don't have a "break" or a goto some other line. We can't say: "Don't, go to the end of the program". Rather, we must build the pathway into the structure of our code by creating inner and outer chunks of logic. ALSO, the creator uses shorthand notes to show how various decision pathways impact a running total score that is used in a final comparison: "if compScore > 30"
Figure 2: Sports and Apple
student flow chart samples
Don't get too rigid about your shapes and symbols. This flow chart is a lovely programming plan for a four-choice decision tree. The author is using a running point total that is adjusted based on the user's response to the questions.
Figure 3: Meatballs
student flow chart samples
A decision structure need not involve only choices between yes/no or another pair of outcomes. This flow chart shows that a decision can be made between three or more possible values of a variable. This is done either with chained if-else blocks or a switch statement.

arrow_upward back up to contents

(c)2023 technologyrediscogvery.net | content can freely reproduced according to the site's content use agreement.