forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanetTester.java
More file actions
37 lines (33 loc) · 972 Bytes
/
PlanetTester.java
File metadata and controls
37 lines (33 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class PlanetTester
{
public static void main(String[] args)
{
Planet mercury = new Planet("Mercury");
Planet venus = new Planet("Venus");
Planet earth = new Planet("Earth");
Planet mars = new Planet("Mars");
Planet saturn = new Planet("Saturn");
Planet jupiter = new Planet("Jupiter");
Planet uranus = new Planet("Uranus");
Planet neptune = new Planet("Neptune");
Planet pluto = new Planet("Pluto");
Planet[] planets = new Planet[9];
planets[0] = mercury;
planets[1] = venus;
planets[2] = earth;
planets[3] = mars;
planets[4] = saturn;
planets[5] = jupiter;
planets[6] = uranus;
planets[7] = neptune;
planets[8] = pluto;
printPlanets(planets);
}
public static void printPlanets(Planet[] planets)
{
for (Planet planet: planets)
{
System.out.println(planet.getName());
}
}
}