Object-Oriented Programming Part 2, OOP Exercise

A: Exercise 5.1 in the book. The topic is the import statement.

B: Exercise 5.5 in the book. The topic is the access modifiers on classes, i.e., private, protected, and public.

C: Exercise 5.6 in the book. The topic is the access modifier protected and access via other classes in the same file.

D: Exercise 5.4 in the book. It is a good idea to added the P class you create to your project code, it is very handy and will save you a lot of typing in the remaining part of the project. Note that the class should be added in the relevant package for example the cs.auc.dk.grp411.util package. 

Extra Assignments

E1: Design a class that can be used to measure the time it executes a piece of code. As an example

Perf.start("Some code");
// complex code 
Perf.measure();
// more complex code
Perf.measure();
Perf.showResult() // prints for example "Some code:" 100ms, "Code 2: " 102 ms
Perf.clean();

What should the interface look like? Which data structures be used internally?

E2: Use the class from E1 to measure the overhead in calling a method for getting and setting a private integer compared to accessing a public integer directly.

E3: Put the code for your project into a globally unique package name. Build a jar file with all your code. Add the jar file to your CLASSPATH. Create a new class that uses the code in your newly created jar file. 

E4: Make your project jar file to an executable jar file (read the documentation on how this is done). Add a class to your project that can be called directly.

Best regards,
Kristian Torp