Question
( JAVA PROGRAMMING ) I need help with this Java Lab Assignment. There are 3 classes(Bestfriend class, Helper class and Main class) which I will
( JAVA PROGRAMMING )
I need help with this Java Lab Assignment. There are 3 classes(Bestfriend class, Helper class and Main class) which I will provide below. I finished the Best friend class that contains the constructors, getters, setters, toString, and a equals Method. I just need help on the other 2 classes. Here's the assignment instructions. After the instructions, I'll place the 3 classes. My teacher placed comments through out the program to help us know what we have to do. In the main class , there are the Add,change, remove and display methods .
ASSIGNMENT ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In the BestFriendSimulation driver class, instantiate a Helper class that will contain an arrayList of BestFriends, and will have all the functionality of updating the arrayList of BestFriend objects.
Then, create a menu that will continue to display until the user requests to exit the menu (loop). That menu will ask the user what they wish to do:
1. Add a BestFriend object to their BFF arrayList 2. Change info of a BestFriend object in their BFF arrayList 3. Remove a BestFriend object from their BFF arrayList 4. Display a. a specific BestFriend's info (using their last name and first name to search) b. all the BFF objects in the arrayList 5. Exit
Create a Helper class that defines the arrayList of BestFriends in its constructor, and then also defines the add, change, display, remove, and error methods as instance methods. Instantiate the Helper class from the driver (main) class. Also in the driver class, create the loop to display and process the menu options. When any specific menu option is selected, call the method from the Helper class.
***Make sure you display a confirmation message after each action selected by the menu. These confirmation messages include:
1. New BFF added. 2. BFF changed. 3. BFF removed. 4. BFF remove CANCELLED (if user enters "no" to "Are you sure you wish to remove...") 5. BFF removed FAILED (is user does not enter either a "yes" or a "no" )
Create a BestFriend domain class with the following attributes: a. first name b. last name c. nick name d. cell phone number e. email address
BEST FRIEND CLASS --------------------------------------------------------------------------------------------------------------------------------------
package skeletonhw;
/** * * @author Belfort's */ public class BestFriend { private String firstName ; private String lastName ; private String nickName ; private String cellPhone ; private String eMail ;
// constructor //public getters public String getLastName () { return lastName ; }
public String getFirstName () { return firstName ; }
public String getNickName () { return nickName ; } // public setters
/** * @param firstName the firstName to set */ public void setFirstName(String firstName) { this.firstName = firstName; }
/** * @param lastName the lastName to set */ public void setLastName(String lastName) { this.lastName = lastName; }
/** * @param nickName the nickName to set */ public void setNickName(String nickName) { this.nickName = nickName; }
/** * @param cellPhone the cellPhone to set */ public void setCellPhone(String cellPhone) { this.cellPhone = cellPhone; }
/** * @param eMail the eMail to set */ public void seteMail(String eMail) { this.eMail = eMail; }
// public ToString
public String toString() { return cellPhone + ". " + firstName + " (" + nickName + ") " + lastName + " "; } }
// equals method
public boolean equals(Object obj) { if( ! (obj instanceof BestFriend ))
{ return false ; } else { BestFriend otherBFF = (BestFriend) obj ; if (otherBFF.getLastName().equalsIgnoreCase(this.getLastName()) )&& otherBFF.getFirstName().equalsIgnoreCase(this.getFirstName())&& otherBFF.getNickName().equalsIgnoreCase(this.getNickName()) return true ; else return false ;
}
HELPER CLASS -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package skeletonhw;
import java.util.ArrayList;
/** * * @author Belfort's */ public class Helper { ArrayList myBFFs = new ArrayList () ;
public void add() { // get the first,last,nicknames, cell phones , email of new bff // create a BFF object // add BFF object to the my BFF'S array List // maybe give a message to acklowledge that a bestfriend has been added }
public void change () { // get the first,last,nickname of bff that is changing // create a search object with only first, last , and nickname values // use a do-while or while loop until you either find the bff object or you reach the end // in the loop, you will ask if this.equals(search) // if not found, say "sorry, bff not found . " // otherwise, ask what do you want to change ? // update the values in the bff object and put it back in array List
}
public void remove () { }
public void display () { }
}
MAIN CLASS ---------------------------------------------------------------------------------------------------------------------------------------------
package skeletonhw;
/** * * @author Belfort's */ public class SkeletonHW {
/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Helper myHelper = new Helper () ;
//1. Display Menu //2. Get users choice //3. While - Loop (User's choice != 5 ) // 3a. INSIDE OF WHILW LOOP ------ use a swtich or an if-statement to determine which of the following methods to call.
// Add-Method myHelper.add() ; // Change-Method myHelper.change(); // remove- method myHelper.remove(); // display method myHelper.display();
// 3.b Display Menu
// 3.c Get users choice
//4. Say "thank you - come again" to user } }
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