CI401 Introduction to Programming - Week 1
Module Introduction; Enhanced for Loop & Making Choices
Commented lab code (read the files in this order)
=======================================================

This is the COMMENTED VERSION, for learning only.
For anything you hand in, use the ORIGINAL lab code (enhanceForChoices.zip
in the "Lecture and lab materials" folder), not these files.

Every file starts with "// What this class does", then short comments on
the Java bits that look strange if you only know Python.
The "_explained" files are FINISHED answers. Try each exercise yourself in
the original enhanceForChoices project first, then compare with these.

FILES IN READING ORDER
----------------------
Lecture and lab examples (read and run these first)
 01  Step01_HelloWorld.java        - your first program: prints Hello World
 02  Step02_HelloBrighton.java     - four printlns in a row (sequence, and lots of repetition)
 03  Step03_HelloPlaces.java       - an array of places + an enhanced for loop, only one println
 04  Step04_HomeTown.java          - an if statement inside the loop: extra message for home
 05  Step05_EstateAgent.java       - an if / else if / else chain: a comment for each room

Lab exercises - finished versions
 06  Step06_HomeTown_explained.java            - Ex_HomeTown: else ("I've never been there") + else if for London
 07  Step07_EstateAgent_Switch_explained.java  - Ex_EstateAgent_Switch: the same tour with switch / case / break

OPTIONAL challenges (only if you want more)
 08  Step08_OPTIONAL_StarRating.java                   - lecture example: stars with a switch and NO break (fall-through)
 09  Step09_OPTIONAL_StarRating_WithBreak_explained.java - the same output with a break after every case
 10  Step10_OPTIONAL_NurseryRhyme_explained.java        - Ex_IfLoop_NurseryRhyme: Ten Green Bottles with a loop and ifs
 11  Step11_OPTIONAL_HotelRatings_explained.java        - Ex_StartRating_Challenging (experienced students): two arrays

(package.bluej is only there so BlueJ opens this folder as a project.)

HOW TO OPEN AND RUN IN BLUEJ
----------------------------
1. Open BlueJ (Windows Start menu, or type BlueJ in the search bar).
2. Click Project, then Open ZIP/JAR...
3. Pick CI401_Week1_Commented_Lab.zip and click Open.
   (BlueJ unpacks it into a folder next to the zip and shows one yellow box per class.
   Your work lives in that unpacked folder, not in the zip.)
4. Click Compile (the button on the left). Striped boxes turn plain when compiled.
5. Right-click a class box, for example Step01_HelloWorld.
6. Click void main(String[] args), then OK.
7. The terminal window opens and shows what the program prints.
   If the star files show ? instead of stars, the program still works; it is just the font.

GLOSSARY
--------
class          The box that holds a program. In Java all code lives inside a
               class. The class name must match the file name exactly
               (class Step01_HelloWorld lives in Step01_HelloWorld.java).
               In BlueJ each yellow box is one class.
method         A named block of instructions you can run, like a Python def.
               run() and main() are methods. Instructions live in methods,
               methods live in classes.
main           The special method Java starts from:
               public static void main(String[] args). BlueJ shows it as
               void main(String[] args) when you right-click a class.
String         Text, such as "Brighton". Written in double quotes.
               Capital S. Like Python str.
int            A whole number such as 5 or 20. Like Python int, but Java makes
               you say the type first: int age = 20;
array          A fixed-length group of values of ONE type, kept together in one
               variable, for example String[] placeList = {"World", "UK"};
               Like a Python list, but it cannot grow or shrink.
semicolon      The ; at the end of each Java instruction. It tells Java
               "this instruction ends here". Python uses the end of the line
               instead. Forgetting it is the most common error.
curly brackets { } mark where a class, method, loop or if block starts and ends.
               Python uses a colon and indentation instead. Every { needs a }.
.equals        How you compare two Strings in Java: place.equals(home).
               Do NOT use == for text. == checks whether they are the very
               same object in memory, which can be false even when the
               letters match. Python just uses == for text.
