Lab3 – CIT325
The goal of this lab is extend the previous lab on moving objects and building a simple GUI.
You are two build a simple GUI to build a rudimentary chat system to reinforce the concept of
communication between objects.
1. Design a Person class with userName and IDNum.
2. Design a Message class, shown below.
3. Design a Chatroom class that uses a client and connects to a ChatServer, of your design.
4. Carry out a conversation between two people by inputting data and posting it to the GUI of
The class you create will be a Person class. The Person class will connect to Chatroom. The
Chatroom 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.
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. For the Message class, there is only 1 attribute, String
message. The required methods are below:
• public void sendMessage(String message)
• public String receiveMessage()
• CurrentPerson – the current person sending a message
• CurrentMessage – the current message being sent/answered
The simple GUI to create will minimally have three simple requirements:
1. JTextField that can take a message as entry
2. JButton that when pressed will take the message entered and send it to another person
3. any other control object that can display all texts submitted with name of sender and text.
You will first instantiate 2 persons into the Chatroom 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
Message: What time is lunch?
Sender Name: Smith
Message: Lunch is at noon.
When complete, show the lab instructor the results for your experiments. Then, ZIP all code and
submit it to Blackboard for this week.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:itcsdx