Problem: You will write a program to manage a list of people attending a confere
ID: 3695783 • Letter: P
Question
Problem:
You will write a program to manage a list of people attending a conference. The conference is on a Saturday and there are two sessions that participants can sign up for. The morning session is from 9 am – 12 pm. The afternoon session is from 1 pm – 4 pm.
The Design:
The classes should be placed in a package with the name edu.ilstu.program6 An input files have been provided. Open and understand the data and the format.
You will need to use the following classes for your program:
Person class
Instance variables:
first name of the conference participant
last name of the conference participant
the name of the company the participant works at
registration code assigned to participant at registration
Methods:
Special constructor that takes a Scanner object. The Scanner object will be used to read data for one participant from the input file.
getters first name, last name and company name
toString method that will build a String literal value using the format below:
Name:
Company:
Session class
Instance variables:
the session time – AM (morning session from 9 – 12 pm) or PM (afternoon session from 1 pm – 4 pm
a Person object to represent the facilitator for the session
an array of Person objects that will represent the participants attending the conference
number of participants already registered for the conference
Constants:
a constant that will hold the maximum number of participants that can sign up for the session. This value would be 30.
Methods:
Special constructor that accepts values for the session time (AM or PM) and a Person object for the facilitator.
a method loadArray that will accept a Scanner object that will be used to read data into Person objects when Person objects are loaded into arrays. You will only load the data for Person objects signed up for the session, i.e. if session time for this object is AM, only load data for AM participants.
a method addToList that will accept a Person object. The Person object represents a participant who just signed up and need to be added to the list.
a method removeFromList that will accept a registration code. The registration code will be used to find the participant in the array and remove the participant from the list of attendees. This method will call the private method that returns the exact location of the participant in the array. The value returned by the private method will be used in the process of removing the participant from the array.
a method changeFacilitator that accepts a Person object which represents the new facilitator being assigned to the session.
a method that will display the contents of the array. It will only display the participants name and company name. Which method should be called?
a private method findParticipant that accepts the registration code of the participant who withdrew from the session. The registration code will be used to search for the participant in the array, and return the index value of where the participant was found in the array. If not found, this method will return a -1.
a method writeToFile that accepts a PrintWriter object. The PrintWriter object will be used to write the contents of the array the output file “UpdatedList.txt” in the same format as the inpur file.
ConferenceApp class:
Open the input file for reading. The input file has been provided, open it and look at the data in it.
Create two (2) Session objects, one for morning and one for afternoon session. Load the arrays of Person objects using the data from the input file into the correct Session object.
Display a menu that the user will select from. The menu should display as follows (:
Conference Registration System
– Add a participant
– Remove a participant
– Change the Facilitator
– Display the list of participants
– Close registration
– Quit
Option 1 – display the number of slots still available in the morning and afternoon session. Then ask the appropriate questions to complete the process of adding a participant to a session, including the registration code. After adding a participant to the list and the maximum number of slots is reached, display the message “Session is full.” Below is just an example.
AM session: 5
PM session: 10
Enter first name: Anne
Enter last name: Dangerfield Enter company name: Haley’s Comet
Enter session: AM
Option 2 – ask the user for the registration code and session time (AM or PM) which will be used to find the participant and remove the participant from the appropriate list.
For option 3 - ask user for the appropriate information needed to complete the process. The registration code for facilitators will be null. Below is just an example:
Enter first name: Anthony
Enter last name: Mallard
Enter Company name: Illinois State University
Option 4 will simply display the list of all participants by session. Display the list of participants in the morning session with the title “Morning Session List”. Then display the list of participants in the afternoon with the title “Afternoon Session List”. There should be a blank line between each participant information.
Morning Session List
…
Afternoon Session List
…
Option 5 will write the contents of the arrays in the Session objects to the same output file, same format as the input file. Display “Registration closed.” when done. Option 6 will terminate the application. You should not need to use “System.exit(#)” to do this. See how it is set up in Lab 14.
If option entered is not 1 – 5, display the message “Invalid option. Please make another selection.”
Input and Output
Input file Participants.txt format:
< first name>
< last name>
< registration code>
Output file:
UpdatedList.txt will hold the updated list of participants in each session. It will have the same format as the input file.
Generating Javadocs
Create javadocs for your Person and Session classes. To do this:
Go to the Project menu and choose Generate Javadoc...
Under the “Select types…” window in the left, expand the folder for Program6, then the src folder. Then select the package name.
After selecting the package name, the classes in this package will appear on the right window. Select Person and Session only.
In the Javadoc command dropdown, select the Configure… button. The location of the Javadoc.exe file needed to generate the javadocs in the virtual machines is in:
C:Program FilesJavajdk1.8.0_65injavadoc.exe
NOTE: For the javadoc files to be correct, all of your javadoc comments must be correct and in the right places in the code. Open the generated html file, read it, correct any poorly formed Javadoc comments in your .java file and recreate the html file as many times as necessary before submitting.
Submission Requirements:
You will generate the javadocs for the Person and Session classes. Read the instructions in the
Zip the entire doc folder with your .java files for all of the classes together into a zip file.
Name the zip file with your initials and Program 6.
o Example format: PM-Program6.zip
Participants.txt :
AM
Carrie
Anderson
Colors Unite
4GH3
AM
Marie Ellen
Smythe
Suncor
233D
PM
James
Hildebrand III
Medco
12R4
AM
Amelia Jane
Foxhill
ConocoPhillips
8776
AM
Aslan
Lionheart
Woodside, Inc.
4534
PM
Matthew
Humphreys
Devon Industries
3GH1
PM
Emma
Woodhouse
Acme Incorporated
SKL2
AM
Eva Nancy
Kelly
Anderson, Ltd.
WTTE
PM
Samuel
King
Reliance
BNN7
AM
Daniel
Woodhouse
Acme Incorporated
RR45
PM
Jennifer
Allegra
International House
12BV
PM
Emma Lynn
Rodriguez
General Electric
AAAA
AM
Carlos Miguel
Villanueva
Generations Plus
34H3
PM
Serena
Marion
Elemental Living
EDDI
AM
Jason
Whitehouse
Accents Inc.
1234
AM
Javier
Lee
TDF Technology
LL2L
AM
Alex
Gunderson
Semantic Living
BNM3
Explanation / Answer
Person.java
public class Person {
//declaring class variables
String firstName,latName,companyName,registrationCode;
//constructor
public Person(String firstName, String latName, String companyName, String registrationCode) {
this.firstName = firstName;
this.latName = latName;
this.companyName = companyName;
this.registrationCode = registrationCode;
}
//getter setter methods
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLatName() {
return latName;
}
public void setLatName(String latName) {
this.latName = latName;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getRegistrationCode() {
return registrationCode;
}
public void setRegistrationCode(String registrationCode) {
this.registrationCode = registrationCode;
}
//toString method
@Override
public String toString() {
return "Person{" + "firstName=" + firstName + ", latName=" + latName + ", companyName=" + companyName + ", registrationCode=" + registrationCode + '}';
}
}
-----------------------------------------------------------------------------------------------------------------------------------
Session.java
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
/**
*
* @author prmsh
*/
public class Session {
//class variables
Person person;
String session;
ArrayList<Person> persons;
int numberParticipants;
int maximum = 30;
//construtor
public Session(Person person, String session, ArrayList<Person> persons, int numberParticipants) {
this.person = person;
this.session = session;
this.persons = persons;
this.numberParticipants = numberParticipants;
}
//setter getter
public Person getPerson() {
return person;
}
public void changeFacilitator(Person person) {
this.person = person;
}
public String getSession() {
return session;
}
public void setSession(String session) {
this.session = session;
}
public ArrayList<Person> getPersons() {
return persons;
}
public void setPersons(ArrayList<Person> persons) {
this.persons = persons;
}
public int getNumberParticipants() {
return numberParticipants;
}
public void setNumberParticipants(int numberParticipants) {
this.numberParticipants = numberParticipants;
}
//adding person object to list
public void addToList(Person person){
persons.add(person);
}
//adding remove from iist
public void removeFromList(String registrationCode){
for(int i=0;i<persons.size();i++){
if(persons.get(i).getRegistrationCode().equals(registrationCode)){
persons.remove(i);
}
}
}
//method to find participant
public int findParticipant(String registrationCode){
int index = 0;
for(int i=0;i<persons.size();i++){
if(persons.get(i).getRegistrationCode().equals(registrationCode)){
index = i;
}
}
return index;
}
//writing to files
public void writeToFile(PrintWriter obj) throws FileNotFoundException, UnsupportedEncodingException{
for(int i=0;i<persons.size();i++){
obj.write(""+persons.get(i));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.