This document discusses adding constructors to a Die class. It explains that constructors are used to create new objects of a class and pass information into the class. The Die class represents a die with properties for the number of sides and side currently on top, and a behavior to roll the die. Constructors can be used to create standard 6-sided dice or dice with any number of sides by passing parameters into the constructor header and call.
This document discusses adding constructors to a Die class. It explains that constructors are used to create new objects of a class and pass information into the class. The Die class represents a die with properties for the number of sides and side currently on top, and a behavior to roll the die. Constructors can be used to create standard 6-sided dice or dice with any number of sides by passing parameters into the constructor header and call.
Last time we designed our Die class and implemented the fields and properties in the class This time, well add our constructors to the class
State, Behavior, and Identity Identity So we can distinguish one object from another Memory address In-Lecture Quiz
To create a new object of a class (called instantiation) we call the
A: police B: cops C: constructor D: healer
Die Class State: number of sides, side thats on top Behavior: roll Identity: when we create a new die object (instantiation) Standard 6-sided die Die with any number of sides (20, for example) In-Lecture Quiz
When we want to pass information in to a constructor, the constructor header needs to have