Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

so the below is the code. our professor which he said do not make change in code. public class ClassDataApp { public static void main(String[]

image text in transcribed

so the below is the code. our professor which he said do not make change in code. public class ClassDataApp { public static void main(String[] args) { int maxSize = 5; ClassDataArray array = new ClassDataArray(maxSize); array.insert("Evans", "Patti", 24); array.insert("Smith", "Lorraine", 37); array.insert("Yee", "Tom", 43); array.displayAll(); array.insert("Adams", "Henry", 63); array.insert("Hashimoto", "Sato", 21); array.delete("Yee"); array.displayAll(); array.insert("Stimson", "Henry", 29); array.insert("Velasquez", "Jose", 73); array.displayAll(); array.delete("Stimson"); array.delete("Hashimoto"); array.delete("Adams"); array.delete("Smith"); array.delete("Evans"); array.displayAll(); array.delete("LaMarque"); array.insert("LaMarque", "Bruno", 54); array.insert("Vang", "Minh", 22); array.delete("Louie"); array.insert("Creswell", "Lucinda", 18); array.delete("Evans"); ifFound(array.find("Creswell")); ifFound(array.find("Louie")); } public static void ifFound(Person person) { if (person == null) { System.out.println("The person was not found in the database."); } else { System.out.print("Found: "); person.displayPerson(); } } }

class Person { String firstName; String lastName; int age;

public Person(String last, String first, int a) { lastName = last; firstName = first; age = a; } public void displayPerson() { System.out.print("Last name: " + lastName); System.out.print(", First name: " + firstName); System.out.println(", Age: " + age + '.'); }

public String getLast() { return lastName; } }

class ClassDataArray { // put your data here public ClassDataArray(int max) { // put your solution here } public Person find(String searchName) { //put your solution here } public void insert(String last, String first, int age) { //put your solution here } public void delete(String searchName) { //put your solution here } public void displayAll() { //put your solution here }

}

Submitting anle upload File Types Java Polnts 20 Available until Feb 26 at 11:59pm For this assignment you are to complete a program that maintains a database of elements from the Person class. The main program and the Person class supplied to you and is completely written. You are not allowed to make any changes to it. You are responsible for complete the ClassDataArray class. The definition of the class and it's framework has been started and supplied to you. You are to complete the methods such that when you run the program it produces the same output that is shown below. You are not allowed to add or delete any methods. You are also not allowed to change the signatures of any methods. Just write your solutions in the commented out areas in the given file. These are the methods that you must implement: the constructor: Creates an object from the Person class. find(): Looks for a person in the database. If the person is found return the person (object). Otherwise return null. insert(): If there is space in the database insert and display the lastname, firstname and age of the person and adjust the total count of people. Insertion should occur in the first available space. Otherwise, it prints an error message. delete(): If the person is in the database, it deletes and displays that person and adjusts the total count of people. Otherwise, it prints an error message. displayA110 : Displays all the lastname, firstname and age of each of the people and the total count of people currently in the database. Here is the starter file you should use: ClassDataApp.java This is what the output of your program must look like: Added: Last name: Evans, First name: Patti, Age: 24. Added: Last name: Smith, First name: Lorraine, Age: 37. Added: Last name: Yee, First name: Tom, Age: 43. Database Display: Last name: Evans, First name: Patti, Age: 24. Last name: Smith, First name: Lorraine, Age: 37. Last name: Yee, First name: Tom, Age: 43. The number items in the database is: 3 Added: Last name: Adams, First name: Henry, Age: 63. Added: Last name: Hashimoto, First name: Sato, Age: 21. Deleted: Last name: Yee, First name: Tom, Age: 43. Database Display: Last name: Evans, First name: Patti, Age: 24. Last name: Smith, First name: Lorraine, Age: 37. Last name: Adams, First name: Henry, Age: 63. Last name: Hashimoto, First name: Sato, Age: 21. The number items in the database is: 4 Added: Last name: Stimson, First name: Henry, Age: 29. Sorry, Velasquez not added. The database is full. Database Display: Last name: Evans, First name: Patti, Age: 24. Last name: Smith, First name: Lorraine, Age: 37. Last name: Stimson, First name: Henry, Age: 29. Last name: Adams, First name: Henry, Age: 63. Last name: Hashimoto, First name: Sato, Age: 21. The number items in the database is: 5 Deleted: Last name: Stimson, First name: Henry, Age: 29. Deleted: Last name: Hashimoto, First name: Sato, Age: 21. Deleted: Last name: Adams, First name: Henry, Age: 63. Deleted: Last name: Smith, First name: Lorraine, Age: 37. Deleted: Last name: Evans, First name: Patti, Age: 24. Database Display: The number items in the database is: Can't delete from an empty database. Added: Last name: LaMarque, First name: Bruno, Age: 54. Added: Last name: Vang, First name: Minh, Age: 22. Not Deleted: Louie could not be found in the database. Added: Last name: Creswell, First name: Lucinda, Age: 18. Not Deleted: Evans could not be found in the database. Found: Last name: Creswell, First name: Lucinda, Age: 18. The person was not found in the database. Previous

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

Students also viewed these Databases questions

Question

Describe the nature of negative messages.

Answered: 1 week ago