OOP Lab Task 2: Diferență între versiuni

De la WikiLabs
Jump to navigationJump to search
Fără descriere a modificării
Linia 11: Linia 11:
== Requirements ==
== Requirements ==


* Write a class called '''PrivateMessage''' which will be used as a data carrier between a chat client and a specific recipient. This class needs to:
* Create a Java application project whose name is <span style="font-family:'Lucida Console', monospace">oop_lab2</span>.
** Store the name of the sender, a message content and the name of the recipient;
* Add to your project the class '''Message''' exactly as defined in OOP Lab Task 1.
** Be immutable
* Add another class, named Inbox, that encapsulates an array of Message objects. The Inbox class fields are:
** Allow reading of the sender and content information from the Message objects in a way specific to private messages in chat programs: "(priv) sender: contents". This must be done with only one method call.
** a reference to an array of Message objects;
** Have a way to read the message recipient from objects of type '''PrivateMessage'''.
** a constant that defines the size of the array;
** two integers that denotes the index of the next free cell in the array and of the oldest unread message;
* Add to the Inbox class a constructor without arguments that instantiates an array of Messages whose size is given by the constant field.
* Add a method, named <span style="font-family:'Lucida Console', monospace">add</span>, which does not return anything and has only one argument, a Message. The method put the new message in inbox at the location indicated by the index of the next free cell.
* Add a method, named <span style="font-family:'Lucida Console', monospace">read</span>, which takes no argument and returns the oldest message, as a formatted string containing the sender and the message content. This method calls one of the Message methods, and also advances the oldest unread message index to the next unread message. If there is no message to retrieve from the inbox, the method returns an empty string and does not advance the index.


* In the existing class '''Main''', instantiate at least 3 objects of type '''PrivateMessage''', and print for each one the formatted string and the recipient.
* Write another class called '''Main''' (the default class created if you created a project within NetBeans), which should contain only the '''main''' method, which instantiates an inbox, adds three messages to the inbox (either created in advance, or instantiated as parameters of the add method calls), and displays the messages read from the inbox (repeatedly calling the inbox read method - try to call it one more time, to see that no more message is displayed).
 
Notes:
* Each class and class member must have one of the three access modifiers ''public'', ''private'' or ''protected''.
* The names of the classes must be identical to the ones specified above.
* Use inheritance and overriding.


Submitting:
Submitting:
* The assignment is submitted attaching the Java source code files exclusively to an e-mail sent to radu.hobincu@upb.ro.
* The assignment will be evaluated automatically by the [http://homework.dcae.pub.ro:8888/Web-CAT/WebObjects/Web-CAT.woa WebCAT] platform.
* The subject of the e-mail will be [POO_2]
* You could access the Web-CAT platform using the username and the password with which you acces the <span style="color:red">electronica.curs.pub.ro</span> intranet.
* The body of the e-mail will contain the name and group of the student and any additional command you want to make.
* Select the Task 2 assignment
* <font color="red">'''Attention'''</font>: Any deviation from these instructions may lead to the loss of the entire amount of points.
* To submit your work you upload a single .zip archive containing only the Java source code files.
* <font color="red">'''Attention'''</font> Any deviation from these instructions may lead to the loss of the entire amount of points.

Versiunea de la data 4 noiembrie 2015 03:45

Required Tutorials

Requirements

  • Create a Java application project whose name is oop_lab2.
  • Add to your project the class Message exactly as defined in OOP Lab Task 1.
  • Add another class, named Inbox, that encapsulates an array of Message objects. The Inbox class fields are:
    • a reference to an array of Message objects;
    • a constant that defines the size of the array;
    • two integers that denotes the index of the next free cell in the array and of the oldest unread message;
  • Add to the Inbox class a constructor without arguments that instantiates an array of Messages whose size is given by the constant field.
  • Add a method, named add, which does not return anything and has only one argument, a Message. The method put the new message in inbox at the location indicated by the index of the next free cell.
  • Add a method, named read, which takes no argument and returns the oldest message, as a formatted string containing the sender and the message content. This method calls one of the Message methods, and also advances the oldest unread message index to the next unread message. If there is no message to retrieve from the inbox, the method returns an empty string and does not advance the index.
  • Write another class called Main (the default class created if you created a project within NetBeans), which should contain only the main method, which instantiates an inbox, adds three messages to the inbox (either created in advance, or instantiated as parameters of the add method calls), and displays the messages read from the inbox (repeatedly calling the inbox read method - try to call it one more time, to see that no more message is displayed).

Submitting:

  • The assignment will be evaluated automatically by the WebCAT platform.
  • You could access the Web-CAT platform using the username and the password with which you acces the electronica.curs.pub.ro intranet.
  • Select the Task 2 assignment
  • To submit your work you upload a single .zip archive containing only the Java source code files.
  • Attention Any deviation from these instructions may lead to the loss of the entire amount of points.