This repository has been archived by the owner on Aug 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
219 lines (207 loc) · 8.66 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
namespace Galaxies_and_Planets
{
//USING APPEND FROM WEB TO IMMITATE Array.Push(item) <3
public static class Extensions
{
public static T[] Append<T>(this T[] array, T item)
{
if (array == null)
{
return new T[] { item };
}
T[] result = new T[array.Length + 1];
array.CopyTo(result, 0);
result[array.Length] = item;
return result;
}
}
// CREATING THE GALAXIES, STARS, PLANETS, MOONS CLASSES
public class Galaxy
{
public string GalaxyName;
public string GalaxyType;
public string GalaxyAge;
public Galaxy(string name, string type, string age)
{
GalaxyName = name;
GalaxyType = type;
GalaxyAge = age;
}
}
public class Star
{
public string StarGalaxyName;
public string StarName;
public decimal StarMass;
public decimal StarSize;
public int StarTemp;
public decimal StarLuminosity;
public Star(string gname, string name, decimal mass, decimal size, int temp, decimal luminosity)
{
StarGalaxyName = gname;
StarName = name;
StarMass = mass;
StarSize = size;
StarTemp = temp;
StarLuminosity = luminosity;
}
}
public class Planet
{
public string PlanetStarName;
public string PlanetName;
public string PlanetType;
public string SupportLife;
public Planet(string starname, string name, string type, string supportlife)
{
PlanetStarName = starname;
PlanetName = name;
PlanetType = type;
SupportLife = supportlife;
}
}
public class Moon
{
public string MoonPlanet;
public string MoonName;
public Moon(string planet, string name)
{
MoonPlanet = planet;
MoonName = name;
}
}
// EDNING OF CREATING THE GALAXIES, STARS, PLANETS, MOONS CLASSES
class Program
{
static void Main(string[] args)
{
//VARIABLES AND ARRAYS
Boolean isGamePlaying = true;
Galaxy[] gArr = { };
Star[] sArr = { };
Planet[] pArr = { };
Moon[] mArr = { };
while (isGamePlaying)
{
//TAKING INPUT
string sentence = Console.ReadLine();
string[] sentenceSplit = sentence.Split();
//STARTING
//ADDING THE GALAXY, STAR, PLANET, EARTH
if(sentenceSplit[0] == "add")
{
if(sentenceSplit[1] == "galaxy")
{
Galaxy newGalaxy = new Galaxy(sentenceSplit[2], sentenceSplit[3], sentenceSplit[4]);
gArr = gArr.Append(newGalaxy);
continue;
}else if(sentenceSplit[1] == "star")
{
Star newStar = new Star(sentenceSplit[2], sentenceSplit[3], Decimal.Parse(sentenceSplit[4]), Decimal.Parse(sentenceSplit[5]), int.Parse(sentenceSplit[6]), Decimal.Parse(sentenceSplit[7]) );
sArr = sArr.Append(newStar);
continue;
}else if(sentenceSplit[1] == "planet")
{
Planet newPlanet = new Planet(sentenceSplit[2], sentenceSplit[3], sentenceSplit[4], sentenceSplit[5]);
pArr = pArr.Append(newPlanet);
continue;
}else if(sentenceSplit[1] == "moon")
{
Moon newMoon = new Moon(sentenceSplit[2], sentenceSplit[3]);
mArr = mArr.Append(newMoon);
continue;
}
}else if(sentenceSplit[0] == "exit")
{
//END OF GAME, THIS SHOULD BE AT THE BOTTOM BUT I DECEIDED IT THIS WAT
Console.WriteLine("YOU HAVE SHUT DOWN THE APP");
isGamePlaying = false;
}else if(sentenceSplit[0] == "stats")
{
//STATS FOR GALAXIES, STARS, PLANETS, MOONS
Console.WriteLine($"----STATS---- \n Galaxies: {gArr.Length} \n Stars: {sArr.Length} \n Planets: {pArr.Length} \n Moons: {mArr.Length} \n ----END OF STATS----");
continue;
}else if (sentenceSplit[0] == "list")
{
//LISTING GALAXIES ETC.
if(sentenceSplit[1] == "galaxies")
{
Console.WriteLine($"---LIST GALAXIES--- \n ");
foreach (Galaxy galaxy in gArr)
{
Console.WriteLine($"{galaxy.GalaxyName}\n ");
}
Console.WriteLine($"--- END LIST GALAXIES--- \n ");
continue;
}else if (sentenceSplit[1] == "stars")
{
Console.WriteLine($"---LIST STARS--- \n ");
foreach(Star star in sArr)
{
Console.WriteLine($"{star.StarName}\n ");
}
Console.WriteLine($"---END LIST STARS--- \n ");
continue;
}else if(sentenceSplit[1] == "planets")
{
Console.WriteLine($"---LIST PLANETS--- \n ");
foreach (Planet planet in pArr)
{
Console.WriteLine($"{planet.PlanetName}\n ");
}
Console.WriteLine($"--- END LIST PLANETS--- \n ");
continue;
}else if(sentenceSplit[1] == "moons")
{
Console.WriteLine($"---LIST MOONS--- \n ");
foreach (Moon moon in mArr)
{
Console.WriteLine($"{moon.MoonName}\n ");
}
Console.WriteLine($"---END LIST MOONS--- \n ");
continue;
}
}else if (sentenceSplit[0] == "print")
{
//PRINT GALAXY DETAILS (WHEN THE CAFFEINE KICKS IN 12:35 AM)
foreach (Galaxy galaxy in gArr)
{
if(galaxy.GalaxyName == sentenceSplit[1])
{
Console.WriteLine($"---Data for {galaxy.GalaxyName}--- \n Type: {galaxy.GalaxyType} \n Age: {galaxy.GalaxyAge} \n Stars:");
//CHECKING FOR STARS IN THE GALAXY
foreach(Star star in sArr)
{
if(star.StarGalaxyName == galaxy.GalaxyName)
{
Console.WriteLine($"Star Name: {star.StarName} \n Star Class: {star.StarMass}, {star.StarSize}, {star.StarTemp}, {star.StarLuminosity}");
//CHECKING FOR PLANETS IN THE STAR SYSTEM
foreach(Planet planet in pArr)
{
if(planet.PlanetStarName == star.StarName)
{
Console.WriteLine($"Planet Name: {planet.PlanetName} \n {planet.PlanetType} \n Support life: {planet.SupportLife}");
//CHECKING FOR MOONS IN THE PLANET ORBIT
foreach(Moon moon in mArr)
{
if(moon.MoonPlanet == planet.PlanetName)
{
Console.WriteLine($"Moons: {moon.MoonName}");
continue;
}
}
}
}
}
}
Console.WriteLine($"--- END DATA FOR {galaxy.GalaxyName}---");
continue;
}
}
}
}
}
}
}