# Tutorial 6 (Feb 4): Classes continued, UML

## Outline

We will go over the following concepts again from last class:

- Class declaration
- Constructors
- Instance methods (sending messages to objects)
- Instance variables
- Creating objects using the
*new*operator

## In-class exercise

The GradeSimulator example last class may have been a little difficult to grasp at the beginning. We will work on a simpler example today called Banking, and I will leave GradeSimulator as an example for your reference.

Download Banking: Handout || Solution || Javadoc (there is no exercise code, we'll start from scratch in class)

Download GradeSimulator: Handout || Exercise || Solution || Javadoc

Other material for reference:

- The supplement slides I made on Classes covers (Revised Feb 6):
- Important! I made a mistake on the last slide using
*this()*as a*constructor.*The correct way is "this(0, 0" and not "this.Point(0, 0)", sorry about that! (Thanks Lisa for catching that.) - main() function
- constructors
- class vs instance
- instance methods
- instance variables
- class methods
- class variables
- access control
*this*keyword

- Important! I made a mistake on the last slide using
- Refer to Tutorial 5 (Feb 2) for how to generate Javadoc
- The examples involving DateTime in Chapter 4 of your textbook.
- This simple game I made, still undocumented.
- UML diagram basics by Beck Hasti @ WISC

## The *Math* class

For Assignment 2, you may need to use the following methods from the *Math class*:

Math.pow(double *baseNumber, *double* exponent)*`double someNumber = 5;`

`double someNumberSquared = Math.pow(someNumber, 2); //25`

Math.sqrt(double *numberToSqrt*)`double anotherNumber = 25;`

`double sqrtOfAnotherNumber = Math.sqrt(anotherNumer); //5`