Answered step by step
Verified Expert Solution
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();
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 (
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