CIT255 Lab4 solution


Original Work ?


5/5 - (2 votes)

The primary goal of this lab is to write, test and complete a system with multiple classes, where
you have designed and implemented those classes. This is a continuation of lab3 and you should
start with that code. This program will have a interactive behavior. This will reinforce the need
for good design and creating and using new classes, where splitting one large class into more logical
classes, as we discussed in class.
The lab will build a rudimentary chat system to reinforce the concept of communication between
1. Design a larger Person class, into multiple classes.
2. Add classes Address, Name and Contact classes to the multi class system.
3. Associate the new classes such as Address, Name and Contact with the Person.
4. Create a textual interface to enter all of the relevant data for all of the class attributes that
are in each object.
5. Create a set of constructors for each class that take a least 1 parameter and set the object
6. Stores the data in the appropriate objects.
7. Extend the chat room class from previous lab.
8. Integrate multiple Person objects into the Chat room object.
9. Carry out a conversation between multiple people by inputting data and posting it to the
console of the Chat room object.
The class you extend will be the Person class. The Person class will connect to Chat room. The
main extension of this lab is to add a lot of information about the person who chats, before they
actually start a chat session. You can add the information through your interface, then instantiate
objects with that data from the beginning. Or, you can instantiate and add it after. A key element
of this lab is how your associate all of the classes together and where you instantiate the objects.
You must decide the correct types for each, and minimally use the attributes and methods listed
below. All behavior from Lab 3 will remain and you will extend the functionality.
Class Person
• First Name
CIT255 Lab4
• Middle Initial
• Last Name
• email
• phoneNumber
• streetAddress
• streetAddress2
• city
• state
• zipCode
• country
• Message
• Question
Class Name
• ???
Class Address
• ???
Class Contact
• ???
Specifications of previous Lab 3
The class you create will be a Person class. The Person class will connect to Chat room. The
Chat room object will allow multiple Person objects to communicate to each other. The class
will contain the following list of data attributes. You must decide the correct types for each, and
minimally use the attributes and methods listed below.
Class Person
• First Name
• Middle Initial
CIT255 Lab4
• Last Name
• Message
• Question
You will need to code a get and set function for each attribute, so minimally 2 methods per each
attribute. You can design more if you want. The required methods are below:
• public void sendMessage(String message)
• public String receiveMessage()
• public void sendQuestion(String question)
• public String receiveQuestion()
Class Chat room
• CurrentPerson – the current person sending a message
• CurrentMessage – the current message being sent/answered
• CurrentQuestion – the current question being sent/answered
You will first instantiate several persons into the Chat room object. Then, go through a continuous
series of interactions (loop) where the you will ask what person, by Last Name, wants to send
a message/question. Then the system will ask what Person object to send the message/question
to. Third, it will ask if you want to send a message or question. Finally, the text of question or
message will be entered. once it is entered, the system will do 2 operations. Update that question or
message into the memory of the person object to which it was intended. Second, display a message
to the screen showing what message has been sent from who to who, whether it is a question or
message and what is the content of the text. This will continue until the user exits with an ”END”
command as the message.
Please begin the chat!
Sender Name: Matson
Receiver Name: Smith
Question or Message: question
Text: What time is lunch?
Matson asked Smith, “What time is lunch?”
Please begin the chat!
Sender Name: Smith
Receiver Name: Matson
Question or Message: message
Text: Lunch is at noon.
Smith said to Matson, “Lunch is at noon.”
CIT255 Lab4
Submit the project file(s) to Blackboard by the required date and time. The grading will be done
in lab, but the documents must be submitted to Blackboard as a backup. This lab ius worth 20