Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the main public class Lab7 { static final String MALE = Male, FEMALE = Female; public static void main(String[] args) { testClientClass(); testNodeClass();

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

this is the main

public class Lab7 { static final String MALE = "Male", FEMALE = "Female"; public static void main(String[] args) { testClientClass(); testNodeClass(); System.out.println(); LinkedListOfClient llc = new LinkedListOfClient(); newClient_insertAtFront(llc, 1, "Ahmad", MALE, true); newClient_insertAtFront(llc, 2, "Hend", FEMALE, true); newClient_insertAtFront(llc, 3, "Fahad", MALE, false); newClient_insertAtFront(llc, 4, "Sara", FEMALE, true); newClient_insertAtFront(llc, 5, "Majed", MALE, true); newClient_insertAtEnd(llc, 6, "Nora", FEMALE, false); newClient_insertAtEnd(llc, 7, "Saad", MALE, false); newClient_insertAtEnd(llc, 8, "Fatema", FEMALE, false); newClient_insertAtEnd(llc, 9, "Ali", MALE, true); newClient_insertAtEnd(llc, 10, "Asma", FEMALE, true); newClient_insertAtEnd(llc, 11, "Mazen", MALE, true); newClient_insertAtFront(llc, 12, "Huda", FEMALE, true); llc.displayAll(); System.out.println(); try { llc.remove(1); System.out.println("Removed client ID 1"); } catch (Exception e) { System.out.println(e); } try { llc.remove(100); System.out.println("Removed client ID 100"); } catch (Exception e) { System.out.println(e); } System.out.println(); llc.displayAll(); System.out.println(); System.out.println("Number of VIP clients " + llc.countClient(true)); System.out.println("Number of non-VIP clients " + llc.countClient(false)); System.out.println(); LinkedListOfClient llcVIP = llc.getClient(true); System.out.println("VIP clients"); llcVIP.displayAll(); System.out.println(); LinkedListOfClient llcNVIP = llc.getClient(false); System.out.println("non-VIP clients"); llcNVIP.displayAll(); System.out.println(); LinkedListOfClient males = new LinkedListOfClient(); LinkedListOfClient females = new LinkedListOfClient(); llc.splitClient(males, females); System.out.println("male clients"); males.displayAll(); System.out.println(); System.out.println("female clients"); females.displayAll(); System.out.println(); } private static void testNodeClass() { Client c1 = null; try { c1 = new Client(1, "", MALE, true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } Node n = new Node(c1); Client c2 = n.getData(); Node n2 = n.getNext(); } private static void testClientClass() { try { Client c1 = new Client(-1, "", MALE, true); int x = c1.getId(); String name = c1.getName(); String gender = c1.getGender(); boolean b = c1.isVip(); String str = c1.toString(); System.out.println(x + name + gender + b + str); } catch (Exception e) { System.out.println(e); } try { Client c1 = new Client(1, "", "Test", true); int x = c1.getId(); String name = c1.getName(); String gender = c1.getGender(); boolean b = c1.isVip(); String str = c1.toString(); System.out.println(x + name + gender + b + str); } catch (Exception e) { System.out.println(e); } } private static Client newClient_insertAtFront(LinkedListOfClient llc, int i, String n, String g, boolean b) { Client c = null; try { c = new Client(i, n, g, b); llc.insertAtFront(c); } catch (Exception e) { System.out.println(e); } return c; } private static Client newClient_insertAtEnd(LinkedListOfClient llc, int i, String n, String g, boolean b) { Client c = null; try { c = new Client(i, n, g, b); llc.insertAtEnd(c); } catch (Exception e) { System.out.println(e); } return c; } }
5. You are not allowed Java Collections like (List, ArrayList, LinkedList ... etc). Use an array otherwise you will receive a ZER0. 6. Write your name and university ID as a comment at the start of all java files. 7. Make sure to use the correct spelling for classes, methods, and variables. Class Client: - Attributes: - id: the is of the client. - name: the name of the client. - gender: the gender of the client. "Male" or "Female". - vip: the client's status. true if VIP, false otherwise. - Methods: + Client(id: int, name: String, gender: String, vip: boolean): throws an exception (IllegalArgumentException) if: id is negative. "ERROR: id can't be negative." gender is not "Male" or "Female". "ERROR: ( gender ) incorrect gender." + getId() + getName() + getGender ( + isVIP( + toString(): returns the Client information. If the client is VIP: Client \# VIP :() If not VIP: Client \# :() Class Node: - Methods: +Node(c: Client ) : constructor. + Getters/Setters Class LinkedListOfClients: - Methods: + LinkedListOfClients () : constructor. + insertAtEnd ( : this method inserts a client at the end of the linked list. + insertAtFront () : this method inserts a client at the front of the linked list. + remove(id: int): this method removes the first client with id equals to id. It throws an exception (Exception) if id is not found. "ERROR: Id ( ) was not found." + countClient( v : boolean): this method returns the number of VIP clients if v is true, non-VIP if v is false. + getClients( v : boolean) this method returns a linked list of VIP clients if v is true, non-VIP if v is false. + splitClients(males: LinkedListOfClient, females: LinkedListOfClient): This method inserts all male clients into linked list males and female clients into females linked list. + displayAll(): displays the data of each employee in the linked list. Implement the previous classes and use the provided Lab7 class to test the classes. Sample Run (Lab7.java) java. lang. IllegalArgumentException: ERROR: id can't be negative. java.lang. IllegalArgumentException: ERROR: (Test) is an incorrect gender. Client \#12 VIP: Huda(Female) Client \#5 VIP: Majed(Male) Client \#4 VIP: Sara(Female) Client \#3 : Fahad(Male) Client \#2 VIP: Hend(Female) Client \#1 VIP: Ahmad(Male) Client \#6 : Nora(Female) Client \#7 : Saad(Male) Client \#8 : Fatema(Female) Client \#9 VIP: Ali(Male) Client \#10 VIP: Asma(Female) Client \#11 VIP: Mazen(Male) Removed client ID 1 java. lang. Exception: ERROR: Id (100) was not found. Client \#12 VIP: Huda(Female) Client \#5 VIP: Majed(Male) Client \#4 VIP: Sara(Female) Client \#3 : Fahad(Male) Client \#2 VIP: Hend(Female) Client \#6 : Nora(Female) Client \#7 : Saad(Male) Client \#8 : Fatema(Female) Client \#9 VIP: Ali(Male) Client \#10 VIP: Asma(Female) Client \#11 VIP: Mazen(Male) Number of VIP clients 7 Number of non-VIP clients 4 VIP clients Client \#12 VIP: Huda(Female) Client \#5 VIP: Majed(Male) Client \#4 VIP: Sara(Female) Client \#2 VIP: Hend(Female) Client \#9 VIP: Ali(Male) Client \#10 VIP: Asma(Female) Client \#11 VIP: Mazen(Male) non-VIP clients Client \#3 : Fahad(Male) Client \#6 : Nora(Female) Client \#7: Saad(Male) Client \#8 : Fatema(Female) male clients Client \#5 VIP: Majed(Male) Client \#3 : Fahad(Male) Client \#7 : Saad(Male) Client \#9 VIP: Ali(Male) Client \#11 VIP: Mazen(Male) female clients Client \#12 VIP: Huda(Female) Client \#4 VIP: Sara(Female) Client \#2 VIP: Hend(Female) Client \#6 : Nora(Female) Client \#8 : Fatema(Female) Client \#10 VIP: Asma(Female)

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

2. What does self-consciousness mean in Meads theory?

Answered: 1 week ago

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago