Question
Hello, I am working on this assignment as outlined below. The assignment is in JAVA. For Project One, which is due in Module Six, you
Hello, I am working on this assignment as outlined below. The assignment is in JAVA.
For Project One, which is due in Module Six, you are asked to develop a mobile application for a customer. The customer will provide you with the requirements. Your job is to code the application and provide unit tests to verify that the application meets the customers requirements. For this milestone, you will focus on delivering the contact services. The purpose of these services is to add, update, and delete contact objects within the application.
The contact service uses in-memory data structures to support storing contacts (no database required). In addition, there is no user interface for this milestone. You will verify the contact service through JUnit tests. The contact service contains a contact object along with the contact service. The requirements are outlined below.
Contact Class Requirements
- The contact object shall have a required unique contact ID string that cannot be longer than 10 characters. The contact ID shall not be null and shall not be updatable.
- The contact object shall have a required firstName String field that cannot be longer than 10 characters. The firstName field shall not be null.
- The contact object shall have a required lastName String field that cannot be longer than 10 characters. The lastName field shall not be null.
- The contact object shall have a required phone String field that must be exactly 10 digits. The phone field shall not be null.
- The contact object shall have a required address field that must be no longer than 30 characters. The address field shall not be null.
Contact Service Requirements
- The contact service shall be able to add contacts with a unique ID.
- The contact service shall be able to delete contacts per contact ID.
- The contact service shall be able to update contact fields per contact ID. The following fields are updatable:
- firstName
- lastName
- Number
- Address
The Contact.java has already been given as this:
package contact;
public class Contact { private String contactId; private String firstName; private String lastName; private String phone; private String address; public Contact (String contactId, String firstName, String lastName, String phone, String address) { if (contactId == null || contactId.length() > 10) { throw new IllegalArgumentException("invalid contact ID"); } if (firstName == null || firstName.length() > 10) { throw new IllegalArgumentException("invalid first name"); } if (lastName == null || lastName.length() > 10) { throw new IllegalArgumentException("invalid last name"); } if (phone == null || phone.length() != 10) { throw new IllegalArgumentException("invalid phone number"); } if (address == null || address.length() > 30) { throw new IllegalArgumentException("invalid address"); } this.contactId = contactId; this.lastName = lastName; this.firstName = firstName; this.phone = phone; this.address = address; }
//getters public String getContactId() { return contactId; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getPhone() { return phone; } public String getAddress() { return address; }
}
At this point, I just need help creating the ContactService.java. Our instructor has asked us to use an arraylist to complete this. We are to implement addContact(), deleteContact(), and updateContact() methods. We should create our own contact ID by incrementing the ID for each contact. The addContact() method should take firstname, lastname, phone, and address parameters and will return the contact. The deleteContact() method will take only the contactId as the parameter. The updateContact() method will take contactId, firstname, lastname, phone, and address as parameters.
So far, I've written this for the ContactService but it is obviously not remotely correct:
package contact;
import java.util.ArrayList;
public class ContactService { //create contactList array private ArrayList
Contact contact = new Contact (contactId, firstName, lastName, Phone, Address);
contactId += contactId;
contactList.add(contactId, firstName, lastName, Phone, Address);
return contact;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started