Personal tools
You are here: Home Members mpate1's Home Lab3
Document Actions

Lab3

by Mit Patel last modified 2006-02-01 02:33 PM

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 :
  1. default: learnMethods(){ //initialize variables}
  2. with parameter: learnMethods(?type ?attribute){//initialize variables}
//methods—at least three
Public: everybody can use it to manipulate a set object.
  1. setM(){}
  2. getM(){}
  3. displayM(){}—not necessary. You will have to do these print statements in main anyway.
  4. 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:
  1. Manipulate it by using the defined methods above.
  2. Have it print something in terminal window.
//Create another object with parameter constructor:
  1. Manipulate it by using the defined methods above.
  2. Have it print something in terminal window.

}//end of main

} //end of class


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: