-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegion.java
226 lines (169 loc) · 6.13 KB
/
Region.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
Template for assignment 1 SENG6110
Name: Neha
Student number: c3396115
Course: SENG6110
Assignment: 1
Date: 24/3/2022
*/
import java.util.*;
public class Region
{
static Scanner console = new Scanner(System.in);
//private Region[] K=new Region[5];
//K[0]=new Region("ceres",0.0,0.0);
private String name ,RegionName,region ;
private double daimeter , radius , orbitalperiod;
private int mass;
private int moons;
private double RegionWidth,PopulationOfObjects;
private int MAX_Planet=5;
private int numberOfPlanets , numberOfRegions;
private int number=0;
private String nameplanet[]=new String[5];
private String nameplanet1[]=new String[5];
private int mass_number=0;
private int daimeter_number=0;
int greatMass[]=new int[MAX_Planet*2];
String planetname[]=new String[10];
double smallDaimeter ,number1;
String smallplanetname;
private double temp=1000 ;
public String getRegionName(){
return RegionName;
}
public double getWidthAU(){
return RegionWidth;
}
public double getPopulationOfObjects(){
return PopulationOfObjects;}
public int getNumberofPlanets()
{ return numberOfPlanets;}
public int getNumberofRegions()
{ return numberOfRegions;}
public int getMassNumber()
{ return number;}
public double getsmallDaimeter()
{ return smallDaimeter;}
public void setRegionName(String input_name){
RegionName= input_name;
}
public void setMassNumber(int massNo){
number=massNo;
System.out.println("Mass_No is set to:"+ number);
}
public void setsmallDaimeter(double dNo){
number1=dNo;
System.out.println("small Daimeter is set to:"+ number1);
}
public void setMassName(String massname){
nameplanet[number]=massname;
System.out.println("Mass_Name is set to:"+ nameplanet[number]);
number++;
}
public void setRegionWidthAU(double Region_Width){
RegionWidth = Region_Width;
}
public void setPopulationOfObjects(double input_population){
PopulationOfObjects= input_population;
}
public void setNumberofPlanets(int num)
{ numberOfPlanets=num;}
// ... etc.
public void setNumberofRegions(int num)
{ numberOfRegions=num;}
Region()
{
RegionName = "";
RegionWidth = 0;
PopulationOfObjects = 0;
}
Region(String m, double o, double p)
{
RegionName = m;
RegionWidth = o;
PopulationOfObjects=p;
}
private DwarfPlanet planet[]= new DwarfPlanet[MAX_Planet];
public void addDwarfPlanet(String region) {
// create new object
// set values of attributes
System.out.println("Add the number of planets you want to add");
numberOfPlanets=console.nextInt();
setNumberofPlanets(numberOfPlanets);
int trillion = 4;
for(int i=0;i<numberOfPlanets;i++)
{ planet[i] = new DwarfPlanet();
System.out.println("Enter the name of Planet");
name=console.next();
planet[i].setName(name);
System.out.println("Enter the mass of the Planet(Unit trillion)");
mass=console.nextInt();
planet[i].setMass(mass);
System.out.println("Enter the Daimeter of the planet");
daimeter=console.nextDouble();
planet[i].setDaimeter(daimeter);
System.out.println("Enter the Radius of the planet");
radius=console.nextDouble();
planet[i].setOrbitalRadius(radius);
System.out.println("Enter the moons of the planet");
moons=console.nextInt();
planet[i].setMoons(moons);
System.out.println("Enter the Period of the planet");
orbitalperiod=console.nextDouble();
planet[i].setOrbitalPeriod(orbitalperiod);
planet[i].setRegion(region);
if(planet[i].getMass()>trillion)
{ System.out.println("Hello");
compareMass(planet[i].getMass(),planet[i].getName());
}
if(planet[i].getDaimeter()<temp)
{ temp = planet[i].getDaimeter();
smallDaimeter(temp,planet[i].getName());}
}
}
public void deleteDwarfPlanet()
{
System.out.println("Deleting the planets");
for(int i=0;i<numberOfPlanets;i++)
{
planet[i]=null;
}
numberOfPlanets=0;}
public void displayRegion()
{ System.out.println("Region Name:"+ getRegionName());
System.out.println("Region Width "+ getWidthAU());
System.out.println("Region Population:"+ getPopulationOfObjects());
}
public void displayDwarfPlanet() {
if(numberOfPlanets==0)
{
System.out.println("Planets were deleted");
}
for(int i=0;i<numberOfPlanets;i++)
{
System.out.println("Name:"+ planet[i].getName());
System.out.println("Region:"+ planet[i].getRegion());
System.out.println("OrbitalRadius:"+ planet[i].getOrbitalRadius());
System.out.println("OrbitalPeriod:"+ planet[i].getOrbitalPeriod());
System.out.println("Daimeter:"+ planet[i].getDaimeter());
System.out.println("Mass:"+planet[i].getMass());
System.out.println("Moons:"+planet[i].getMoons());
System.out.println("Name:"+planet[i].getName());
}
}
public void compareMass(int mass, String name)
{
greatMass[mass_number]=mass;
planetname[mass_number]=name;
System.out.println(greatMass[mass_number]);
mass_number=mass_number+1;
System.out.println(mass_number);
setMassNumber(mass_number);
}
public void smallDaimeter(double daimeter , String name)
{
smallDaimeter=daimeter;
setsmallDaimeter(smallDaimeter);
}
}