Computers and Technology

In a bestfriendsimulation driver class, define and initialize a reference variable called mybestfriends referencing an arraylist ofbestfriend objects. then, create a menu that will continue to display itself, and process the requests of the user, until the user requests to exit the menu (loop).the menu should have 5 menu options: 1.) add a bestfriend to the arraylist called mybestfriends; 2.) change a bestfriend in the arraylist; 3.) remove a bestfriend from the arraylist; 4.) display all the objects in the mybestfriends arraylist. 5.) exitfor each of these menu options, be sure to prompt the user for the necessary information such as bestfriend's first name, last name, nickname, and cell phone number. hint: in order to be able to change a bestfriend's information or remove a bestfriend from the arraylist, you will have to create a loop that will search the mybestfriends arraylist from beginning to end, and store the index position of the bestfriend that will be updated or removed. if the desired bestfriend is not found, a -1 will be returned from the search, or a not found flag will be set. if the bestfriend is found, use that index position to either change or remove that object from the mybestfriends arraylist. make sure you test each of your menu options, and then select the option that prints the table immediately afterwards, to ensure the phonebook looks correctly.1. create the bestfriend domain classdefine and/or instantiate the private static and non-static fields. create the constructorpublic class bestfriend{ private static int friendnumber = 0; private int friendidnumber; private string firstname; private string lastname; private string nickname; private string cellphonenumber; public bestfriend (string afirstname, string alastname, string anickname, string acellphonenumber) { firstname = afirstname; lastname = alastname; nickname = anickname; cellphonenumber = acellphonenumber; friendnumber++; friendidnumber = friendnumber; } public string tostring( ) { return friendidnumber + ". " + nickname + " " + firstname + " " + lastname + " " + cellphonenumber; }create the set methods (setters)create the get methods (getters)public boolean equals(object another){ if (another instanceof bestfriend ) { bestfriend anotherbff = (bestfriend) another; if (firstname. equalsignorecase(anotherbff. firstname) & & lastname. equalsignorecase(anotherbff. lastname) // & & nickname. equalsignorecase(anotherbff. nickname) & & // cellphone. equalsignorecase(anotherbff. cellphone)) return true; } return false; }2. create the bestfriendsimulation driver class: instantiate an arraylist called mybffscreate a do …… while loop to create a menu of 5 choices (add, change, remove, display, exit)allow the user to input the choice. use an if statement (or switch) to execute the user’s choice. there are many ways to accomplish this task: technique #1.) create a 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 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 class. technique #2.) instantiate the driver class in the main method (instantiate its own self). then, define instance methods in the driver class for the add, change, display, remove, and error methods. call them from the menu loop. technique #3.) in the driver class, create static methods for the add, change, display, remove, and error methods. call them from the menu loop. in any of the above 3 techniques, the arraylist of bestfriends can be defined as a global variable, so that it does not have to be passed as a parameter to each of the add, change, display, remove, and error methods. similarly, the scanner keyboard object should also be defined as a global variable too. the alternative to defining the arraylist and scanner keyboard as global variables is to pass these as parameters to each method call. for example: addbff(mybffs, keyboard); expert answer

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:10, Metlife
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, opgbadwolf5
What provides an array of buttons for quick access to commonly used commands and tools
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, small77
Font size, font style, and are all aspects of character formatting.
Answers: 2
image
Computers and Technology, 23.06.2019 16:00, natasniebow
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
Do you know the correct answer?
In a bestfriendsimulation driver class, define and initialize a reference variable called mybestfrie...

Questions in other subjects:

Konu
Spanish, 03.04.2020 04:10