This is a collection of odds and ends.
Getter and Setter methods. The way to provide "outsiders" with access to a private class field is to use getter's and setters. For example the Device class has a private field called viewNormal. To provide access one should add a routine (aka member function) like
public Vector3f getViewNormal() { return viewNormal; }
In this case there is no need for other classes to change viewNormal. (Well at least in the context of project1.) But it there was one could add a setter method like:
public void setViewNormal(Vector3f vN) { viewNormal = vN; }This method fails to keep the viewNormal normalized so a more realistic setter method might be
public void setViewNormal(Vector3f vN) { viewNormal = vN; fixView(); }
jdb the Java Debugger We went over a jdb session. The first step is to compile the program with debuuging turned on. This is done via the -g flag, so one can recompile for debugging by
rm *.class javac -g *.javaBe careful to remove class files and not java source files.
Here is the output of a jdb session on Device.java
jar files are the best way to distribute java programs. Jar files are like zip files or compressed tar files. Surpose you want to turn in project 1, the way to do this is with a single jar file. Do these steps.
Manifest-Version: 1.0 Main-Class: Device
jar cmf manifest.mf yourname.jar *.class *.java ReadMe
java -jar yourname.jar
The options to jar are much like the options to tar. In particular, jar tf foo.jar will list the table of contents of the jar file and jar xf foo.jar will extract all the files from the jar file.