A2 • Classes, Arrays, File I/O

The goals of this assignment are to help you learn how to:

  • write a Java class
  • add components to a lanterna-based app
  • use and ArrayList of objects
  • write to a file

Getting Started

To start, create a directory named a2 (lowercase a) in your repository and change your working directory to a2.

Next, execute the following commands to download the starter files for this assignment.

$ curl -O www.n0code.net/work/teaching/courses/csci200/code/contacts/Makefilecurl -O www.n0code.net/work/teaching/courses/csci200/code/contacts/ContactsApp.java
$ curl -O www.n0code.net/work/teaching/courses/csci200/code/contacts/Contact.java

Now, compile the source code by issuing the following command.

$ make

And now run the app using the following command.

$ make run

TODO

  1. Add the following fields along with getters and setters to Contact.java.  Note: You do not need to validate the input at this time.
    • First Name
    • Last Name
    • Mobile Phone
    • Personal Email
    • Web Page
  2. Add the following to ContactsApp.java
    • Labels and TextBoxes for each of the fields in Contact.java.
    • Code in SaveButtonHandler so that when the user presses the “Queue Contact” button, the newContact object has all of its fields set.
    • Code in WriteButtonHandler so that when the user presses the “Write To File” button, all of the fields of each contact are written to contacts.txt. Include colons between the field data.
  3. When you’ve completed he assignment do the following:
    • Run make clean to remove all class files from your working directory.
    • Add a2 to your repository’s staging area
    • Commit the changes to your repository
    • Push your changes to GitHub

Due: 8:00 a.m. on Monday, January 22.

About the author