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) · 1.09 KB
/
Copy pathPlanetTester.java
File metadata and controls
37 lines (33 loc) · 1.09 KB
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 jupiter = new Planet("Jupiter");
Planet saturn = new Planet("Saturn");
Planet uranus = new Planet("Uranus");
Planet neptune = new Planet("Neptune");
Planet pluto = new Planet("Pluto");
Planet[] namesOfPlanets = new Planet[9];
namesOfPlanets[0] = mercury;
namesOfPlanets[1] = venus;
namesOfPlanets[2] = earth;
namesOfPlanets[3] = mars;
namesOfPlanets[4] = jupiter;
namesOfPlanets[5] = saturn;
namesOfPlanets[6] = uranus;
namesOfPlanets[7] = neptune;
namesOfPlanets[8] = pluto;
for(Planet planet:namesOfPlanets)
{
System.out.println(planet.getName());
}
for(int i = 0; i < namesOfPlanets.length; i++)
{
System.out.println(namesOfPlanets[i].getName());
}
}
}