Lab3
Full Class definition
- Learn how and when to use public and private.
- Creating methods similar to set and get methods I will go over in class.
- Create attributes and use types such as String and int
- Create objects using constructors.
- Use methods to manipulate objects.
A Class Definition that you have to follow:
/* Create a class to understand methods, constructors, objects etc…
*
*Come up with a class.
*Make use of types such as String and int.
*Don't forget to comment everything.
*
*@author, @date, @lab3 (group)
*/
public class learnMethods {
- //list of types and attributes
- Private: no one can change it
- //constructors---at least two
- With and without parameters :
- default: learnMethods(){ //initialize variables}
- with parameter: learnMethods(?type ?attribute){//initialize variables}
- //methods—at least three
- Public: everybody can use it to manipulate a set object.
- setM(){}
- getM(){}
- displayM(){}—not necessary. You will have to do these print statements in main anyway.
- someM(){}: create a method that does something. i.e. increment(), decrement() from integer class.
public static void main (System args[]){
- //Create a new object with default constructor:
-
- Manipulate it by using the defined methods above.
- Have it print something in terminal window.
- //Create another object with parameter constructor:
-
- Manipulate it by using the defined methods above.
- Have it print something in terminal window.
}//end of main
} //end of class