mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zanninso
2632926739
|
1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago |
README.md
StarGetters
Instructions
Now, we will update the accessibility of the properties.
In order to still have access to them, we need to implement getters and setters for each property :
getX
andsetX
for thex
propertygetY
andsetY
for they
propertygetZ
andsetZ
for thez
propertygetName
andsetName
for thename
property
Usage
Here is a possible ExerciseRunner.java to test your function :
public class ExerciseRunner {
public static void main(String[] args) {
CelestialObject defaultStar = new CelestialObject();
System.out.println(defaultStar.getX());
System.out.println(defaultStar.getY());
System.out.println(defaultStar.getZ());
System.out.println(defaultStar.getName());
defaultStar.setName("Terre");
defaultStar.setX(0.43);
defaultStar.setY(0.98);
defaultStar.setZ(1.43);
System.out.println(defaultStar.getX());
System.out.println(defaultStar.getY());
System.out.println(defaultStar.getZ());
System.out.println(defaultStar.getName());
}
}
and its output :
$ javac *.java -d build
$ java -cp build ExerciseRunner
0.0
0.0
0.0
Soleil
0.43
0.98
1.43
Terre
$