double
The names of the variables are up to the programmer, but it is helpful to give them meaningful names.
Here is Cone
with some parts filled in
filled in:
public class Cone { // instance variables private double radius; // radius of the base private double height; // height of the cone // constructor // methods }
(Review: ) An instance variable is a variable that holds part of the state of an object. Each object (each "instance" of the class) contains its own instance variables. Instance variables hold on to their values as long as the object exists. An assignment statements can change the value in an instance variable, but otherwise it holds its value for the lifetime of the object.
(Review: ) What must the constructor of Cone
be named?