OOP Lab Task 1: Diferență între versiuni

De la WikiLabs
(Requirements)
(Requirements)
 
(Nu s-au afișat 2 versiuni intermediare efectuate de același utilizator)
Linia 9: Linia 9:
 
== Requirements==
 
== Requirements==
  
* Create a Java application project whose name is <span style="font-family:'Lucida Console', monospace">oop_lab1</span>.
+
* Create a Java application project.
* Add to your project a class '''Message''' (that may be used some time in the future as a data carrier between a chat client and all the other clients connected to a server). This class needs to:
+
* Add a new package and give it the name <span style="font-family:'Lucida Console', monospace">labutil</span>. This package will contain all classes that you will implement during this and next laboratories.
** Store the name of the sender and a message body.
+
* Add to this package a class named '''Message''' (it will be used later during this semester to carry messages between chat clients for a distributed chat application). This class needs to:
** Be immutable (once an object of this type is created, its content cannot be changed).
+
** Store the name of the sender and the text of the message (the message body).
** Allow reading of the sender and message body from Message objects in a way specific to chat programs: "sender:contents". This must be done using only one method call that returns the formatted string, ready to be displayed by any print method. Try first with a method of your own. Then, add another method, that does exactly the same thing but whose declaration is <span style="font-family:'Lucida Console', monospace">public String toString()</span>.
+
** Be immutable (once an object of this class is created and initialized, its content - the sender name and message body - cannot be changed).
 +
** Allow reading of the sender's name and of the message body from Message objects in a format specific to chat programs: <span style="font-family:'Lucida Console', monospace;color:fuchsia;">sender: message</span>. This way you allow the user of the '''Message''' class (you will use it inside the '''Main''' class, therefore you will be such a user) to call a method that returns the formatted string, ready to be displayed by any print method of the ''System.out'' object. Add to the '''Message''' class a method of your own (give it whatever name you like,  such as ''print'', or ''read'') that returns the sender's name and the message body as a single string formatted as required. Then, add another method that does exactly the same thing but whose declaration is <code style="color:green;">public String toString()</code>.
  
* Write another class called '''Main''' (the default class created if you created a project within NetBeans), which should contain only the '''main''' method, that instantiates three objects of type '''Message''' and then displays for each of them their formatted string on the screen using the System.out print method, first with a single String argument, the String returned by your method from Message class, and then with the object's reference as its sole argument.
+
* Add to this package another class called '''Main''', which should contain only the '''main''' method, that instantiates three objects of type '''Message''' and then displays for each of them their formatted string on the screen using one of the System.out print methods, first with a single String argument, the String returned by your method from Message class, and then with the object's reference as its sole argument.
  
 
Notes:
 
Notes:
 
* Each class and class member must have one of the two access modifiers ''public'' or ''private''.
 
* Each class and class member must have one of the two access modifiers ''public'' or ''private''.
* The names of the classes must be identical to the ones specified above.
+
* The package name and the name of classes must be identical to the ones specified above.
 
* Follow the coding rules stated in Java Coding Conventions.
 
* Follow the coding rules stated in Java Coding Conventions.
  
Submitting:
+
== Submitting ==
 
* The assignment will be evaluated automatically by the [http://homework.dcae.pub.ro/WebObjects/Web-CAT.woa Web-CAT] platform.
 
* The assignment will be evaluated automatically by the [http://homework.dcae.pub.ro/WebObjects/Web-CAT.woa Web-CAT] platform.
 
* 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.
 
* 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.

Versiunea curentă din 9 noiembrie 2016 23:26

Required Tutorials

Requirements

  • Create a Java application project.
  • Add a new package and give it the name labutil. This package will contain all classes that you will implement during this and next laboratories.
  • Add to this package a class named Message (it will be used later during this semester to carry messages between chat clients for a distributed chat application). This class needs to:
    • Store the name of the sender and the text of the message (the message body).
    • Be immutable (once an object of this class is created and initialized, its content - the sender name and message body - cannot be changed).
    • Allow reading of the sender's name and of the message body from Message objects in a format specific to chat programs: sender: message. This way you allow the user of the Message class (you will use it inside the Main class, therefore you will be such a user) to call a method that returns the formatted string, ready to be displayed by any print method of the System.out object. Add to the Message class a method of your own (give it whatever name you like, such as print, or read) that returns the sender's name and the message body as a single string formatted as required. Then, add another method that does exactly the same thing but whose declaration is public String toString().
  • Add to this package another class called Main, which should contain only the main method, that instantiates three objects of type Message and then displays for each of them their formatted string on the screen using one of the System.out print methods, first with a single String argument, the String returned by your method from Message class, and then with the object's reference as its sole argument.

Notes:

  • Each class and class member must have one of the two access modifiers public or private.
  • The package name and the name of classes must be identical to the ones specified above.
  • Follow the coding rules stated in Java Coding Conventions.

Submitting

  • The assignment will be evaluated automatically by the Web-CAT platform.
  • You could access the Web-CAT platform using the username and the password with which you acces the electronica.curs.pub.ro intranet.
  • If your username and password are valid you should be able to enter your Web-CAT student page (but there is still no course attached to you). If you are unable to access electronica.curs.pub.ro, contact the UPB net administrator.
  • To be enrolled in the OOP lab on the Web-CAT platform you should first access the Web-CAT platform and then add your identification info (intranet username, name, surname, group, e-mail address) into the user registration document. Your registration is checked by the administrator, therefore it may finish after a couple of days.
  • Once you are enrolled in the Web-CAT OOP lab, you may submit your work to the active task assignments.
  • To submit your work you upload a single .zip archive containing only the Java source code files.
  • If your work contains a single Java file you may directly upload that single file, unarchived.
  • Attention Any deviation from these instructions may lead to the loss of the entire amount of points.