Solved! Need help with my Java programming assignment

Not open for further replies.


Jul 6, 2012
Hi! I just started my programming class and we have been given an assignment to complete by the 18th of september. Ive been told the assignment is really easy but even so im struggeling quite a bit... the task is as follows (we use javaBluej) im really stuck at the whole boolean thing with getters and setters for isOnline.

In this task you will implement two classes: Person and Message. You will create both classes in a new project in BlueJ.
All class names, variables and methods are named in English. The Person class should contain two private fields: name of type string and isOnline type boolean. The message class must have two fields: messageBody of type String and send by Type of Person.
Note that the Message class is dependent on the Person class. In order for BlueJ to understand the Person type when implementing the Message class, you may already have created that class when you create Message. As we will see in task 1.c), Person will also know the Message class.

1.a) The Person class must have a constructor who takes the parameter: the player's name. The name should not be changed so you should not create a set method for it. The field isOnline should have a getter and setter the way we have discussed lectures and should be set to false in the constructor.

1.b) The Message class must have a constructor that takes two parameters.
First parameter is sending by Type of Person, and Second parameter is messageBody of type String. Both of these parameters should set the value of the corresponding fields. Note that since the fields have the same name as the parameters, you can use the keyword this in the assignment.

1.c) The Person class must have a method receiveMessage, with the following signature:
public void receive message (message message)
The method should print to the terminal (see example on the right): • A line beginning with From:, continues with the sender's name and, finally, whether the sender is online. • A line beginning with Two: and ending with the name of the recipient. • A line containing only Message :. • Message text.
From: Odd (online) To: Even Message: Hi, Even! Shall we have a coffee?

What i have managed to do is the following: for the class person.
public class Person
// The fields
private String name;
private boolean isOnline;

//constructor with user`s name as parameter
public Person(String personName) {
name = personName;

//constructor for isOnline with getter and setter
public String getisOnline () {
return isOnline;
public void setisOnline (boolean isOnline) {
isOnline = false;

//method for printing out info

and the following for the class message.

public class Message
{ //The Fields
private String MessageBody;
private String senderPerson;

//constructor with parameters for person and messagebody
Not open for further replies.
Thread starter Similar threads Forum Replies Date
aymen9309 Apps General Discussion 1
SyndiShanX Apps General Discussion 1
D Apps General Discussion 1
BlueMoon1890 Apps General Discussion 0
Neon The (Anthro) Umbreon Apps General Discussion 1
K Apps General Discussion 2
T Apps General Discussion 10
M Apps General Discussion 2
R Apps General Discussion 3
S Apps General Discussion 2
N Apps General Discussion 1
P Apps General Discussion 4
A Apps General Discussion 8
M Apps General Discussion 6
S Apps General Discussion 1
L Apps General Discussion 5
C Apps General Discussion 3
S Apps General Discussion 1
7 Apps General Discussion 5
randomizer Apps General Discussion 0