LD03: Non-OOP Classes due Wed 31 Jan 10:00

\begin{purpose}
In this assignment you will:
\begin{itemize}
\item Create a ...
...tinue working with {\tt git} from the command-line
\end{itemize}
\end{purpose}

Preparation for Lab Day

Do these steps:
  1. In your workspace, make sure you have the latest homework files from the base repository (git pull origin) and, if necessary, the latest files from your bitbucket repository (git pull mine).
  2. In the provided hw03 directory create a new class called Movie that will store movie information (title, genre, and year) for a single movie.
  3. Add JavaDoc comments to document your new class.
  4. In the same directory create a source file named Driver.java that will contain main() and will be used for the purpose of testing your new movie class. Add JavaDoc comments to this new file as well.
  5. In Driver.java (heretofore known as “the driver”) create an instance of your Movie class, initialize it and print its contents to verify it is working.
  6. Commit your changes and then push the changes to bitbucket.

Lab Day

For this lab day you can work on the lab computers or on your own computer (if it is with you in the lab). In the instructions below, the term “your workspace" refers to the files you are working on whether they are on your own computer or on the lab computer.

  1. In your workspace make sure you have the most recent code from the base repository and from your homework repository on bitbucket.

  2. Open the Driver.java you created in the prelab assignment and show it to the lab instructor.

  3. Take a moment to read the sample code and commentary in the section called “Constructors” found in the CSCI 2320 Command Sheet (with commentary) document. Pay special attention to the use and explanation of the this keyword.

  4. Modify the Movie class to have a constructor with three parameters used to initialize the object. Modify the driver code to demonstrate your constructor.

  5. Commit your changes.

  6. Now read the commentary and section called toString() found in the CSCI 2320 Command Sheet (with commentary) document. The purpose of overriding the toString() method is to make it convenient to display the contents of an object.

  7. Write a toString() method that returns all parts of a Movie object. Then test the your code in the driver.

  8. Commit your changes.

  9. Java's built-in String class provides a static method called format(). A static method can be invoked using the name of the class like this:
    String fun;
    fun= String.format("%6.1f %s",9.293,"Fred");
    System.out.println(fun);
    
    This method returns a String that has been formatted as if it were being printed using printf. So, the above command would store: " 9.3 Fred" in fun (notice the three leading spaces).

    If you don't remember how the printf command formats output you should take a moment to read about it in the section called “Formatted Output” in the CSCI 1320 Command Sheet (with commentary) document. Then take a look at the printf command used in the display() method of the program we are working on.

  10. Modify your toString() method to return a formatted string that will match the format currently used in the display() method. This will come in handy later.

  11. Commit your changes. Then push your lab day work to your BitBucket repository. If there is time remaining show your work to the instructor.

  12. If you finish early begin work on the homework assignment.