Assignment 2 - Get Classey

Table of contents

  1. Lab Goals:
  2. Final Result:
  3. Part 1: Person Generator:
    1. Grading
  4. Part2: Person Reader
    1. Grading

Lab Goals:

  1. Practice creating classes and instantiating objects.
  2. Instantiate object using data from a text file.
  3. Persist Object data to a text file.
  4. Store and Manipulate class objects with an ArrayList

Final Result:

You will be submitting a git repository with the following naming convention, 2-get-classy-<your-github-username>, (i.e., 2-get-classy-Ygilany). The repository contains:

  1. one Java Project with the following files:
  2. Person.java (a class to represent a person object)
  3. PersonGenerator.java (has a main method)
  4. PersonReader.java (has a main method)
  5. SafeInput.java (The source file is available with the assignment instructions)
  6. The output text file from the PersonGenerator program.
  7. a modified README.md file that includes your self-assessment

Part 1: Person Generator:

  1. Create a Person.java class to represent a Person Object.
Person  
Fields  
 String ID; 
 String firstName; 
 String lastName; 
 String title;Mr., Mrs., Ms., Prof., Dr., Hon., …
 int YOB;- Year of Birth
- Range should be 1900-2010
- make sure validations happen in the constructor as well as the setter method.
Methods  
 Constructor 
 Getters and Setters 
 public String fullName()returns a concatenation of the first and last names
 public String formalName()returns a concatenation of the title and the full name
 public static int getAge(int year)- A static method that takes a year and returns an age.
- Use the Calendar Object to get current Year (may requires a bit of web search)
 public String toCSVDataRecord()- returns a comma separated value (csv) String suitable to writing to a java text file.
- Make sure to use this function when saving data to the file.
- (i.e., 0001,John, Doe,Mr., 2000)
  1. Create a program (Java main class) called PersonGenerator.java.
    • a user will input the data to the console.
    • a Person object is created for each entry.
    • Store all the Person objects in an ArrayList<Person>
    • Export all the Person objects to a text file using the toCSVDataRecord() method

Grading

  • The program runs with no errors.
  • The Person class includes all the fields and methods specified above.
  • Usage of the Calendar object to calculate age in the getAge method.
  • The program properly instantiates objects using the class constructor.
  • The program properly stores the Objects in an ArrayList.
  • Proper usage of Git and GitHub (frequent commits, explanatory commit messages)

Part2: Person Reader

  1. Create a program (Java main class) called PersonReader.java.
    • Use the JFileChooser to prompt the user to select the file you export in Part 1.
    • Instantiate a Person Object for each record you read from the file.
    • Store all the Person Objects in an ArrayList<Person>.
    • Use the String.format or System.out.printf method to create a neatly formatted columnar display of the data.
ID    Firstname    Lastname   Title    YOB
==================================================
0001  John         Doe        Mr.      1990
0002  Jane         Doe        Mrs.     1993

Grading

  • The program runs with no errors.
  • The program properly uses the JFileChooser.
  • The program properly instantiates objects using the class constructor.
  • The program properly stores the Objects in an ArrayList.
  • The program output is formatted properly.
  • Proper usage of Git and GitHub (frequent commits, explanatory commit messages)