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.
 
 
 
 
 
 
davhojt 1cf114eb85
docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine
1 year ago
..
README.md docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine 1 year ago

README.md

StarConstructors

Instructions

We will now add two constructors :

  • The default one, with no parameter which inits the properties to the following values :
    • x : 0.0
    • y : 0.0
    • z : 0.0
    • name : "Soleil"
  • The second one take four parameters and sets the values of name, x, y and z.

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.x);
        System.out.println(defaultStar.y);
        System.out.println(defaultStar.z);
        System.out.println(defaultStar.name);

        CelestialObject earth = new CelestialObject("Terre", 0.43, 0.98, 1.43);
        System.out.println(earth.x);
        System.out.println(earth.y);
        System.out.println(earth.z);
        System.out.println(earth.name);
    }
}

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
$ 

Notions

Class
Property