import java.util.ArrayList; public class QuizShow { private String showTitle; //show title private Name hostName; //host name private ArrayList contestant; //contestant database //No-Arg Constructor public QuizShow() { showTitle = ""; hostName = new Name(); contestant = new ArrayList<>(); //instantiate the ArrayList of Contestants } //Parametized Constructor public QuizShow(String title, Name host) { showTitle = title; hostName = host; contestant = new ArrayList<>(); //instantiate the ArrayList of Contestants } //setters public void setShowTitle(String title) { showTitle = title; } public void setHostName(Name host) { hostName = host; } //getters public String getShowTitle() { return showTitle; } public Name getHostName() { return hostName; } public Contestant getContestant(int index) { return contestant.get(index); //uses ArrayList method .get() } public int getNumContestants() { return contestant.size(); //uses ArrayList method .size() } //method addContestant - adds new Contestant to the end of the ArrayList public void addContestant(Contestant newContestant) { contestant.add(newContestant); //uses ArrayList method .add() } //method reviseContestantInfo - revises info for an existing Contestant public void reviseContestantInfo(int index, Contestant myContestant) { contestant.set(index, myContestant); //myContestant info has been revised } //method updateContestantInfo - updates info for an existing Contestant public boolean updateContestantInfo(Contestant myContestant) { int index = findContestant(myContestant); if(index != -1) { contestant.set(index, myContestant); //myContestant info has been updated return true; } else return false; } //method findContestantByName - searches Contestant database by name public int findContestantByName(Name myName) { String firstName1, firstName2; String lastName1, lastName2; for(int index = 0; index < contestant.size(); index++) { firstName1 = contestant.get(index).getName().getFirst(); firstName2 = myName.getFirst(); lastName1 = contestant.get(index).getName().getLast(); lastName2 = myName.getLast(); if(lastName1.equals(lastName2) && firstName1.equals(firstName2)) return index; //myName found in Contestant database } return -1; //myName not found in Contestant database } //method findContestant - Note: this is a private method private int findContestant(Contestant myContestant) { String firstName1, firstName2; String lastName1, lastName2; for(int index = 0; index < contestant.size(); index++) { firstName1 = contestant.get(index).getName().getFirst(); firstName2 = myContestant.getName().getFirst(); lastName1 = contestant.get(index).getName().getLast(); lastName2 = myContestant.getName().getLast(); if(lastName1.equals(lastName2) && firstName1.equals(firstName2)) return index; //myContestant found in Contestant database } return -1; //myContestant not found in Contstant database } }