Week 5 -  Study guide  

You will need to do a lot of private study on this topic to ensure you grasp it fully.

1.   Work your way through pages 1-12 and follow all the programs carefully. Check that you understand:-

If you have difficulty  grasping the concept an animated example in the online material may help. See the link from the schedule page.

2. Study question  on the  tutorial sheet 1    and prepare  it. 

Read the notes on driver programs on page 17. Have a look at the supplied driver program for questions 1. TestComm.java  and make sure you understand its purpose. If not make a note to ask questions about it at your tutorial. 

3. Study questions 2 and 3 on tutorial sheet 1 and prepare them.  Use the driver  TestAllowance.java  for Q2 and TestCels.java

for Q3


4. Now continue studying chapter 6 notes

Study pages 13 - 18. Note the program CarHire.java  consists of a main method calling two other methods.

Note how the logical sequence of events is clear in the main program but we have removed the details  to lower methods. This is known as abstraction.  The details of how to read and check the car type is hidden from main.  It delegates the task to the method getCarType().  See how the method gets called in main()

carType = getCarType();

In order to evaluate the expression on the right side of the = sign  the method getCarType is called and all statements are executed. Note processing stays in the ,method getCarType until the user enters a correct character.  Then the character is returned by the statement

return ctype ;

This will cause processing to recommence where it left off in main. The assignment statement gets completed so the returned value is put into the variable carType in main.

Now continue working your way through the program and follow carefully what happens when the calcCharge method gets called. 


5.  Study the question in tutorial sheet tutorialsheet 2  and prepare Q1 either option 1 or option 2. For Option1 prepare the code for the main program. For option 2 see below.

Option 2

Before tackling option 2 read the notes on top down development on page 17. 

Read the tutorial sheet 2 .and see if you follow what is required for option 2.  Prepare the code  to be added to   PrintTemps.java 

Complete chapter 6 notes

Read through the notes on the math class and see can you follow the program TestRandom on page 22

Note you can download any of the programs in these notes.