Class Student
java.lang.Object
|
+--Student
- public class Student
- extends java.lang.Object
Student Class. Is created and given a string for a name.
Students are the primary kind of "agent" in this model.
Constructor Summary |
Student(java.lang.String s)
Create a student and tell it its name |
Method Summary |
java.lang.String |
getName()
Return the student's name string |
void |
receiveMessage(Student obj,
java.lang.String s)
The Student object receives a message from "obj" and the
content of the message is a String s
Note I'm inconsistent here in setting a precise type for
obj in this method, whereas I used Object in sayHiTo(). |
void |
sayHi()
This is a diagnostic method. |
void |
sayHiTo(java.lang.Object target)
The student is supposed to send a message to the target Object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Student
public Student(java.lang.String s)
- Create a student and tell it its name
sayHiTo
public void sayHiTo(java.lang.Object target)
- The student is supposed to send a message to the target Object.
Please note that the target is cast as a Student before it is told
what to do. You might have other kinds of targets and then you
would need a different cast.
receiveMessage
public void receiveMessage(Student obj,
java.lang.String s)
- The Student object receives a message from "obj" and the
content of the message is a String s
Note I'm inconsistent here in setting a precise type for
obj in this method, whereas I used Object in sayHiTo().
getName
public java.lang.String getName()
- Return the student's name string
sayHi
public void sayHi()
- This is a diagnostic method. When a student is told to sayHi(),
it just prints a line to the terminal telling its name.
This way, I can check if a student exists.