Java: Create Class of Contact List and Person then Provide Fake Recording and API Document

  1. Home
  2. Homework Library
  3. Computer Science
  4. Java Programming
  5. Java: Create Class of Contact List and Person then Provide Fake Recording and API Document
Subject Computer Science Java Programming

Question

Final Project Part 1

A class skeleton for each class you will create. A class skeleton includes just the variables and the first line of the methods that will be implemented in each class.

Your completed skeleton will also include a main() that

i) creates an object of each of the other classes,
ii) calls each method on each of the objects it creates, and
iii) prints a message at the end that shows that the entire program compiled and ran.

You must submit the class skeleton source code files together with a recording of the run (copy and paste the console to the bottom of the main().) Be sure that each person puts their initials in a comment by the code that they write.

A list of the prewritten classes and interfaces that you will be using. These are classes and interfaces from the Java API that you plan on using.

A specification for the user interface for your Contact List. This will be a recording of the run of your program after you have fully implemented all of the use cases. Since your program is not written yet, you will need to type this "fake recording" into an editor, word processor or Google doc. NO DESCRIPTION is called for here! What you type will be exactly what will appear on the console when your completed program runs. Text that will not appear on the console when your completed Task 4 runs does not belong here! This document will make sure that everyone on the team is clear about what you are trying to build.

Below is the requirement for the coding:
QualitySoft: Use Cases for Contact List Project
We have contracted with the client to implement and test the following five use cases.

Use Case Name: Enter a new person into the contact list
ID number: 1
Actors: user
Preconditions: The user has chosen to enter a new person into the contact list
Primary course: The user enters first name, last name, street address, email address, phone number and notes.
Alternate course: If the user leaves one or more of the fields blank, the person will still be entered into the contact list.
Exception course: If the user leaves the last name blank, then the person will not be entered into the contact list.
Postconditions: The new person is stored in the contact list in memory.

Use Case Name: Print the contact list
ID number: 2
Actors: user
Preconditions: The user has chosen to print the entire contact list
Primary course: The system prints all information about all contacts to the console, sorted by last name.
Alternate courses: none
Exception courses: none
Postconditions: The contact list is printed to the console, sorted by name. If there are two contacts with matching last names, these two contacts will be ordered by first name.

Use Case Name: Retrieve a person's information by last name
ID number: 3
Actors: user
Preconditions: The user has chosen to retrieve a person's information from the contact list by last name
Primary course: The user enters a last name, and the system displays all of the information that was previously entered on that person.
Alternate courses:
1) If there is no one in the contact list with the given last name, the system will display a message to the user telling her that.
2) If there is more than one person in the contact list with the given last name, then all of the people with that last name will be displayed.
Exception courses: none
Postconditions: All contacts with the given last name are displayed.

Use Case Name: Quit the program and save to disk
ID number: 4
Actors: user
Preconditions: The user has chosen to quit the contact list program.
Primary course: The system saves the current contact list to disk and exits gracefully.
Alternate courses: none
Exception courses: none
Postconditions: There is a data file on the disk containing all of the current contact information.

Use Case Name: Start the program and open the existing data file on disk
ID number: 5
Actors: user
Preconditions: The user has chosen to start the contact list program.
Primary course: The system finds the current contact list file on disk, opens it and reads it into the list in memory.
Alternate courses: If there is no contact list data file on disk, then the system begins with an empty contact list.
Exception courses: none
Postconditions: There is a contact list in memory containing any contacts that were entered previously.
The following Use Case #1a would be "nice to have." This use case would replace the Use Case #1 as specified above. Do not spend any time working on this until you have a fully functioning program that satisfies the first 5 use cases.

Use Case Name: Enter a new person
ID number: 1a
Actors: user
Preconditions: The user has chosen to enter a new person into the contact list
Primary course: The user enters first name, last name, street address, email address, phone number and notes.
Alternate courses:
1) If the user leaves one or more of the fields blank, the person will still be entered into the contact list.
2) If the user cancels out of the operation in the middle, the person will not be entered into the contact list.
Exception courses:
1) If the user leaves the last name and/or the first name blank, then the person will not be entered into the contact list.
2) If the user enters an email address that does not satisfy the correct syntax for an email address, the system asks the user to reenter.
3) If the user enters a phone number that does not satisfy the correct syntax for a phone number, the system asks the user to reenter.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

/**
*
* @author
*/
public class Main {

    /**
    * main function
    *
    * @param args
    */
    public static void main(String[] args) {

       int option = 0;
      
       // i) creates an object of each of the other classes,
       ContactList list = new ContactList();
       Scanner scanner = new Scanner(System.in);
       String fileName;
       String lastName;

       // ii) calls each method on each of the objects it creates, and
       do {
            System.out.print("Enter your option\n"
                   + "0. Quit & Save\n"
                   + "1. Add a new person to contact list\n"
                   + "2. Read contact from a file\n"
                   + "3. Show contact by last name\n"
                   + "4. Show all contact\n"
                   + "--> ");
            option = Integer.parseInt(scanner.nextLine());

            switch (option) {
                case 0:
                   System.out.print("Enter a file name to save to: ");
                   fileName = scanner.nextLine();
                   list.saveToFile(fileName);
                   break;
                case 1:
                   list.addPerson(getPerson(scanner));
                   break;
                case 2:
                   System.out.print("Enter a file name to read from: ");
                   fileName = scanner.nextLine();
                   list.readFromFile(fileName);
                   break;
                case 3:
                   System.out.print("Enter a last name to search for: ");
                   lastName = scanner.nextLine();
                   list.showPersonByLastName(lastName);
                   break;
                case 4:
                   System.out.println("All contact:");
                   list.printContact();
                   break;
            }

       } while (option != 0);

       // iii) prints a message at the end that shows that the entire program compiled and ran.
       System.out.println("");
       System.out.println("All contact:");
       list.printContact();
    }...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Gradebook Using Java Programming
Homework Solution
$20.00
Java
Programming
Computer Science
Random Numbers
Scores
Students
Input
Output
Loops
Statements
Conditions
Average Values
Variables
Mathematics
Java Program For Vending Machine
Homework Solution
$40.00
Java
Programming
Computer Science
Vending Machine
Drinks
Password
Screen
Inventory
Menu
Errors
Money
Multiplication Table in Java
Homework Solution
$40.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Rows
Columns
Input
Output
Integers
Strings
Multiplication
Tables
Operations
Conditions
Personal Name List in Java
Homework Solution
$8.00
Java
Programming
Computer Science
Codes
Algorithms
Personal Name List
Records
Errors
Arrays
Items
Variables
Statements
Characters
Moving Elements
Input
Output
Java Program: Arrays Of Marks
Homework Solution
$30.00
Java
Programming
Codes
Computer Science
Algorithms
Arrays
Marks
Characters
Strings
Integers
Maximum Value
Minimum Value
Difference
Range
Median
Sorting Methods
Boundaries
Statements
Vaariables
Binary Tree in Java
Homework Solution
$40.00
Java
Programming
Coding
Computer Science
Binary Tree
Data
Generic Types
Functions
Variables
Recursive Methods
Nodes
Input
Output
Get help from a qualified tutor
Live Chats