Technical University of Denmark DTU
02115   Java Programming
Autumn 2011

Week plan #4

For the week   19. September - 23. September


Preparations for the week

The lectures of the last week has given a fair coverage of sections 6.1 - 6.4 of Chapter 6 and has shown how to record a test and thus automatically build a simple (maybe too simple) test method for double booking. Also it was introduced how to take advantage of the setUp() method to hold fixtures (that are statements which will be executed before every test method is activated).

Details on handling fixtures - section 6.4.4 (pages 185-186) - should be studied carefully. And as told on the plan for last week in the section After the lectures: Don't forget the remaining parts of the chapter (pages 186-200). Those parts could be useful in relation to doing the coming mandatory assignment.


The situation for the subjects of Chapter 7 is that the practical things have been demonstrated together with some reasons for making the improvements of the design and implementation of the zool game. But I left out the general concepts and much of the important background reasoning:



In the last week one of the questions was: How to avoid duplicate code within the same class ?
    Use a private auxiliary method holding the common code.

In this week one qustion is: How to avoid duplicate code and fields in a number of related classes ?
    Use inheritance from a common super class.


Inheritance is the subject of Chapters 8 and 9. To be introduced just study Chapter 8 of BK to the following extent:

  1. Chapter 8: 8.1 - 8.5; pages 245-264:


The lectures

We will cover selected parts of the textbooks, primarily the following parts of BK
  - Chapter 8, pages 245-274
  - Chapter 9, pages 276-298



Exercises at the PC's

Exercises are taken solely from the BK textbook:

How to run Java Precisely examples using BlueJ
Say, you want to incorporate Example60 of the PS textbook as a BlueJ project:
  1. Open BlueJ and ask for New Project
  2. Give the project a name - as e.g. Example60
  3. Then Close the project
  4. In the file system the project Example60 is a directory to which you has to copy the file Example60.java from the collection of ready-to-run programs from the Java Precisely textbook
  5. Then in BlueJ choose Open Project on project Example60 which now holds the class Example60
  6. Compile the Java class
  7. Right click on Example60 and select the method void main(String[]) to execute


After the lectures

The lectures has not covered all details of the chapters 8 and 9 of BK. Work through the missing parts and do the exercises missed at the exercise class, refer to the section above, with the supplements mentioned below as a minimum.

At the end of this week you are supposed to be familiar with the following parts of the BK textbook:



Besides the above mentioned sections of the PS textbook read the following sections:
Jens Thyge Kristensen, Email: jtk@imm.dtu.dk

Newest edition:   14. September (The section 'How to run Java Precisely examples using BlueJ' has been added)
Previous editions:
    - 13. September
    -   8. April (just the heading and footing)