Exercise 5.1 in the book. The topic is the import
statement.
Exercise 5.5 in the book. The topic is the access modifiers on
classes, i.e., private
, protected
, and
public
.
Exercise 5.6 in the book. The topic is the access modifier
protected
and access via other classes in the same file.
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.
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?
Use the class from Exercise E1 to measure the overhead in calling a method for getting and setting a private integer compared to accessing a public integer directly.
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.
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.