Course Links

Resources

External

This lab will introduce you to Java classes, and take you through a simple process for developing them.

The Java compiler is named javac. It does not take a -o flag and output file name, since every class compiles into it its own .class file. To run, you invoke the Java virtual machine on a class containing a main method (note the lack of the .jave suffix in this step). Below are the commands to compile and run the demo files from the lab.

javac ClockTime.java TestClockTime.java Test.java
java TestClockTime

To Do

Download the zip file containing all the files for this lab. Unlike some of our other labs, it is divided into multiple folders, one for each part of the lab. Begin with part 1, and continue on to the next part as you finish the ones before. You will be building your own class as you go, called Money.java. To complete each part you should have a program that compiles and runs, passing all tests. Each time you move on to a new part, you should copy your work from the previous folder into the next one. Here are some commands that may be useful:

In case you get stuck, I am providing links to solution files for each of the parts of the lab: part 1, part 2 Try not to use these until you are done and checking your answers.