diff --git a/MyFirstUniverse/.idea/.gitignore b/MyFirstUniverse/.idea/.gitignore new file mode 100644 index 0000000..1c2fda5 --- /dev/null +++ b/MyFirstUniverse/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/MyFirstUniverse/.idea/description.html b/MyFirstUniverse/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/MyFirstUniverse/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/MyFirstUniverse/.idea/discord.xml b/MyFirstUniverse/.idea/discord.xml new file mode 100644 index 0000000..2a6a89a --- /dev/null +++ b/MyFirstUniverse/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/encodings.xml b/MyFirstUniverse/.idea/encodings.xml new file mode 100644 index 0000000..ab2dc53 --- /dev/null +++ b/MyFirstUniverse/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/misc.xml b/MyFirstUniverse/.idea/misc.xml new file mode 100644 index 0000000..7e211a1 --- /dev/null +++ b/MyFirstUniverse/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/modules.xml b/MyFirstUniverse/.idea/modules.xml new file mode 100644 index 0000000..774cf7c --- /dev/null +++ b/MyFirstUniverse/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/project-template.xml b/MyFirstUniverse/.idea/project-template.xml new file mode 100644 index 0000000..d57a956 --- /dev/null +++ b/MyFirstUniverse/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/uiDesigner.xml b/MyFirstUniverse/.idea/uiDesigner.xml new file mode 100644 index 0000000..b93ac08 --- /dev/null +++ b/MyFirstUniverse/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/.idea/vcs.xml b/MyFirstUniverse/.idea/vcs.xml new file mode 100644 index 0000000..61684b6 --- /dev/null +++ b/MyFirstUniverse/.idea/vcs.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/MyFirstUniverse.iml b/MyFirstUniverse/MyFirstUniverse.iml new file mode 100644 index 0000000..9465dd8 --- /dev/null +++ b/MyFirstUniverse/MyFirstUniverse.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/Main.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/Main.class new file mode 100644 index 0000000..4a5f996 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/Main.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/CosmicBody.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/CosmicBody.class new file mode 100644 index 0000000..a335e12 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/CosmicBody.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Planet.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Planet.class new file mode 100644 index 0000000..d2deaeb Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Planet.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/SolarSystem.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/SolarSystem.class new file mode 100644 index 0000000..82f275a Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/SolarSystem.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Star.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Star.class new file mode 100644 index 0000000..89be626 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Star.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Сomet.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Сomet.class new file mode 100644 index 0000000..abc5fdb Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/cosmicbody/Сomet.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Galaxy.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Galaxy.class new file mode 100644 index 0000000..f6a06f5 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Galaxy.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/PlanetaryNebula.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/PlanetaryNebula.class new file mode 100644 index 0000000..23b9112 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/PlanetaryNebula.class differ diff --git a/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Universe.class b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Universe.class new file mode 100644 index 0000000..8f91a68 Binary files /dev/null and b/MyFirstUniverse/out/production/MyFirstUniverse/com/company/universe/Universe.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/Main.class b/MyFirstUniverse/out/production/OOP/com/company/Main.class new file mode 100644 index 0000000..4a5f996 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/Main.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/CosmicBody.class b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/CosmicBody.class new file mode 100644 index 0000000..a335e12 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/CosmicBody.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Planet.class b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Planet.class new file mode 100644 index 0000000..d2deaeb Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Planet.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/SolarSystem.class b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/SolarSystem.class new file mode 100644 index 0000000..82f275a Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/SolarSystem.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Star.class b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Star.class new file mode 100644 index 0000000..89be626 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Star.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Сomet.class b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Сomet.class new file mode 100644 index 0000000..abc5fdb Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/cosmicbody/Сomet.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/universe/Galaxy.class b/MyFirstUniverse/out/production/OOP/com/company/universe/Galaxy.class new file mode 100644 index 0000000..f6a06f5 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/universe/Galaxy.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/universe/PlanetaryNebula.class b/MyFirstUniverse/out/production/OOP/com/company/universe/PlanetaryNebula.class new file mode 100644 index 0000000..23b9112 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/universe/PlanetaryNebula.class differ diff --git a/MyFirstUniverse/out/production/OOP/com/company/universe/Universe.class b/MyFirstUniverse/out/production/OOP/com/company/universe/Universe.class new file mode 100644 index 0000000..8f91a68 Binary files /dev/null and b/MyFirstUniverse/out/production/OOP/com/company/universe/Universe.class differ diff --git a/MyFirstUniverse/src/com/company/Main.java b/MyFirstUniverse/src/com/company/Main.java new file mode 100644 index 0000000..7b26f5d --- /dev/null +++ b/MyFirstUniverse/src/com/company/Main.java @@ -0,0 +1,42 @@ +package com.company; + +import com.company.cosmicbody.Planet; +import com.company.cosmicbody.SolarSystem; +import com.company.cosmicbody.Star; +import com.company.universe.PlanetaryNebula; +import com.company.universe.Universe; + +public class Main { + + public static void main(String[] args) { + Universe myuniverse = new Universe(); + myuniverse.startUniverse(); + + PlanetaryNebula orion = new PlanetaryNebula("Orion",5, 18000,200,200,200); + PlanetaryNebula buba = new PlanetaryNebula("Buba", 8, 2300, 12,59,94); + PlanetaryNebula phonk = new PlanetaryNebula("Phonk", 20, 100000, 0,0,0); + + Planet Mercury = new Planet("Mercury", 1333, 6083); + Planet Venus = new Planet("Venus", 4867, 938); + Planet Earth = new Planet("Earth", 100000, 108321); + Planet Mars = new Planet("Mars", 641, 16318); + Planet Jupiter = new Planet("Jupiter", 3, 71313); + Planet Saturn = new Planet("Saturn", 1000, 108408); + Planet Uranus = new Planet("Uranus", 1000, 202156); + Planet Neptune = new Planet("Neptune", 7050, 620654); + + Star sun = new Star("Sun", 1.392, 1.40927, 1499726.85); + SolarSystem solarSystem = new SolarSystem(); + solarSystem.addBody(Mercury); + solarSystem.addBody(Venus); + solarSystem.addBody(Earth); + solarSystem.addBody(Mars); + solarSystem.addBody(Jupiter); + solarSystem.addBody(Saturn); + solarSystem.addBody(Uranus); + solarSystem.addBody(Neptune); + + + myuniverse.stopUniverse(); + } +} \ No newline at end of file diff --git a/MyFirstUniverse/src/com/company/cosmicbody/CosmicBody.java b/MyFirstUniverse/src/com/company/cosmicbody/CosmicBody.java new file mode 100644 index 0000000..75edda2 --- /dev/null +++ b/MyFirstUniverse/src/com/company/cosmicbody/CosmicBody.java @@ -0,0 +1,13 @@ +package com.company.cosmicbody; + +public class CosmicBody { + private String body; + + public String getBody() { + return body; + } + + protected void setBody(String body) { + this.body = body; + } +} diff --git a/MyFirstUniverse/src/com/company/cosmicbody/Planet.java b/MyFirstUniverse/src/com/company/cosmicbody/Planet.java new file mode 100644 index 0000000..12b70c4 --- /dev/null +++ b/MyFirstUniverse/src/com/company/cosmicbody/Planet.java @@ -0,0 +1,103 @@ +package com.company.cosmicbody; + +public class Planet extends CosmicBody { + private String name; + private double weight; + private double diameter; + private double gravitation; + private Boolean weightSet = false; + + public void setPlanetaryWeight(double weight){ + if(!weightSet){ + setWeight(weight); + weightSet = true; + } + } + + + public double getWeight() { + return weight; + } + + private void setWeight(double weight) { + if(this.weight>weight){ + if(Math.abs(this.weight-weight) <= 1000){ + System.out.println("I'm losing weight."); + } + else { + System.out.println("I am very poor."); + } + } + else{ + if(Math.abs(this.weight-weight) <= 1000){ + System.out.println("Damn, I woke up."); + } + else { + System.out.println("Damn, I put on too much weight."); + } + } + + if(Math.abs(this.weight-weight)>1000){ + increaseGravity(0.1); + } else { + decreaseGravity(0.1); + } + + this.weight = weight; + } + + public double getDiameter() { + return diameter; + } + + private void setDiameter(double diameter) { + this.diameter = diameter; + } + + public String getName() { + return name; + } + + private void setName(String name) { + this.name = name; + } + + public double getGravitation() { + return gravitation; + } + + public void setGravitation(double gravitation) { + this.gravitation = gravitation; + } + + public Planet(String name, double weight, double diameter) { +// setWeight(weight); +// setDiameter(diameter); +// setName(name); + this.name = name; + this.weight = weight; + this.diameter = diameter; + this.gravitation = 9.81; + } + + private void increaseGravity(double add){ + gravitation = gravitation + add; + } + private void decreaseGravity(double dec){ + gravitation = gravitation - dec; + } + + public Planet(String name, double weight, double diameter, double gravitation) { + this.name = name; + this.weight = weight; + this.diameter = diameter; + this.gravitation = gravitation; + } + +// public Planet() { +// this.name = "Zem"; +// this.weight = 5972200; +// this.diameter = 12756; +// } + +} diff --git a/MyFirstUniverse/src/com/company/cosmicbody/SolarSystem.java b/MyFirstUniverse/src/com/company/cosmicbody/SolarSystem.java new file mode 100644 index 0000000..fdf486d --- /dev/null +++ b/MyFirstUniverse/src/com/company/cosmicbody/SolarSystem.java @@ -0,0 +1,40 @@ +package com.company.cosmicbody; + +public class SolarSystem { + private Star Sun = new Star(); + + private Planet Earth; + private Planet Mars; + private Planet Jupiter; + private Planet Saturn; + + private CosmicBody[] orbitalBody = new CosmicBody[500000000]; + private int objectCounter; + + public SolarSystem() { + //star = new Star(); + + setObjectCounter(0); + orbitalBody[objectCounter] = new Planet("Mars", 432432, 432432); + objectCounter++; + + orbitalBody[objectCounter] = new Planet("Venusa", 55, 32342); + objectCounter++; + + orbitalBody[objectCounter] = new Star("Polar",0,0,0); + objectCounter++; + } + + public void addBody(CosmicBody newBody){ + orbitalBody[objectCounter] = newBody; + objectCounter++; + } + + public int getObjectCounter() { + return objectCounter; + } + + public void setObjectCounter(int objectCounter) { + this.objectCounter = objectCounter; + } +} diff --git a/MyFirstUniverse/src/com/company/cosmicbody/Star.java b/MyFirstUniverse/src/com/company/cosmicbody/Star.java new file mode 100644 index 0000000..e73564f --- /dev/null +++ b/MyFirstUniverse/src/com/company/cosmicbody/Star.java @@ -0,0 +1,64 @@ +package com.company.cosmicbody; + +public class Star extends CosmicBody { + private String name; + private double weight; + private double radius; + private double temperature; + private Boolean light = false; + + public Star(String name, double weight, double radius, double temperature) { + this.name = name; + this.weight = weight; + this.radius = radius; + this.temperature = temperature; + } + + public Star(){ + this.name = "naname"; + this.weight = 1000^35; + this.temperature = 500000; + } + + void on(){ + this.light = true; + this.temperature = temperature + 10000; + } + + void off(){ + this.light = false; + this.temperature = temperature - 1000; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getWeight() { + return weight; + } + + public void setWeight(double weight) { + this.weight = weight; + } + + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius = radius; + } + + public double getTemperature() { + return temperature; + } + + public void setTemperature(double temperature) { + this.temperature = temperature; + } +} diff --git a/MyFirstUniverse/src/com/company/cosmicbody/Сomet.java b/MyFirstUniverse/src/com/company/cosmicbody/Сomet.java new file mode 100644 index 0000000..630946a --- /dev/null +++ b/MyFirstUniverse/src/com/company/cosmicbody/Сomet.java @@ -0,0 +1,21 @@ +package com.company.cosmicbody; + +public class Сomet extends CosmicBody { + private int object_counter; + + private CosmicBody[] orbitalBody = new CosmicBody[500000000]; + + public Сomet() { + setObject_counter(0); + orbitalBody[object_counter] = new Сomet(); + object_counter++; + } + + public int getObject_counter() { + return object_counter; + } + + public void setObject_counter(int object_counter) { + this.object_counter = object_counter; + } +} diff --git a/MyFirstUniverse/src/com/company/universe/Galaxy.java b/MyFirstUniverse/src/com/company/universe/Galaxy.java new file mode 100644 index 0000000..913c373 --- /dev/null +++ b/MyFirstUniverse/src/com/company/universe/Galaxy.java @@ -0,0 +1,28 @@ +package com.company.universe; + +import com.company.cosmicbody.SolarSystem; + +public class Galaxy { + + private String name; + private SolarSystem[] systems = new SolarSystem[500000000]; + private int objectCounter; + + public Galaxy(String name) { + this.name = name; + this.objectCounter = 0; + } + + public void addSustava(SolarSystem system){ + this.systems[objectCounter] = system; + this.setObjectCounter(this.objectCounter++); + } + + public int getObjectCounter() { + return objectCounter; + } + + private void setObjectCounter(int objectCounter) { + this.objectCounter = objectCounter; + } +} diff --git a/MyFirstUniverse/src/com/company/universe/PlanetaryNebula.java b/MyFirstUniverse/src/com/company/universe/PlanetaryNebula.java new file mode 100644 index 0000000..265368e --- /dev/null +++ b/MyFirstUniverse/src/com/company/universe/PlanetaryNebula.java @@ -0,0 +1,25 @@ +package com.company.universe; + +public class PlanetaryNebula { + + private String name; + private long size; + private long lifeDuration; + private long x, y , z; + +// public PlanetaryNebula(){ +// size = 0; +// lifeDuration = 0; +// x = 0; y = 0; z=0; +// } + + public PlanetaryNebula(String name,long lifeDuration, long size, long x, long y, long z) { + this.name = name; + this.lifeDuration = lifeDuration; + this.size = size; + this.x = x; + this.y = y; + this.z = z; + } +} + diff --git a/MyFirstUniverse/src/com/company/universe/Universe.java b/MyFirstUniverse/src/com/company/universe/Universe.java new file mode 100644 index 0000000..a90d873 --- /dev/null +++ b/MyFirstUniverse/src/com/company/universe/Universe.java @@ -0,0 +1,39 @@ +package com.company.universe; + +public class Universe { + private boolean state; + private long size; + + public Universe() { + state = false; + size = 0; + } + + public void startUniverse(){ + state = true; + System.out.println("World is ready\n"); + increaseSize(); + decreaseSize(10000); + } + + public void stopUniverse(){ + state = false; + System.out.println("\nWorld is stop"); + } + + private void increaseSize(){ + while (size<999000){ + size++; + //System.out.println("Wait. Universe " + size + "km3"); + } + System.out.println("Universe is " + size + "km3"); + } + + private void decreaseSize(long desiredSize){ + while (size > desiredSize){ + size--; + //System.out.println ("Wait. Compressed world " + size + "km3"); + } + System.out.println ("Compress world is " + size + "km3\n"); + } +}