Create Objects and Call Instance Methods
|
Grab a Piece of Paper! |
Calculator Class Methods
The following is a diagram of a Calculator class.
Class Name: Calculator Class |
Constructor:
|
Data/Attributes:
|
Methods/Behaviors:
|
Use the Java Playground
- Predict the output from running the body of main for testing.
- Run the code to determine if your prediction was correct.
- Call each of the other methods in the table above and print their values to the screen.
Dice Class Code
The following is a diagram of a Dice class.
Class Name: Dice Class |
Constructors:
|
Data/Attributes:
|
Methods/Behaviors:
|
Use the Java Playground
- Predict the output from running the body of main for testing.
- Run the code to determine if your prediction was correct.
- Add the following statements:
- add statements to call the accessor method and print the number of sides.
- add a statement to change the number of sides to 10.
- add statements to roll the dice and print the value.
- add a statement to use the toString method.
- Run the code to test the additions you have mad to main
LocalDate Instance Methods
Practice calling methods with the LocalDate class.