From 7eed6569c49df7c9214533a3bbe1b6f49d8ac995 Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Tue, 29 Nov 2022 23:09:03 +0100 Subject: [PATCH] V2 --- MyFirstUniverseV2/.idea/description.html | 1 + MyFirstUniverseV2/.idea/discord.xml | 7 + MyFirstUniverseV2/.idea/encodings.xml | 6 + MyFirstUniverseV2/.idea/misc.xml | 12 ++ MyFirstUniverseV2/.idea/modules.xml | 8 + MyFirstUniverseV2/.idea/project-template.xml | 3 + MyFirstUniverseV2/.idea/uiDesigner.xml | 124 +++++++++++++ MyFirstUniverseV2/.idea/vcs.xml | 6 + MyFirstUniverseV2/.idea/workspace.xml | 173 ++++++++++++++++++ MyFirstUniverseV2/MyFirstUniverse.iml | 11 ++ MyFirstUniverseV2/src/com/company/Main.java | 144 +++++++++++++++ .../com/company/cosmicbody/CosmicBody.java | 13 ++ .../src/com/company/cosmicbody/Earth.java | 27 +++ .../src/com/company/cosmicbody/Planet.java | 106 +++++++++++ .../com/company/cosmicbody/SolarSystem.java | 40 ++++ .../src/com/company/cosmicbody/Star.java | 68 +++++++ .../src/com/company/cosmicbody/Сomet.java | 21 +++ .../src/com/company/creature/Bezstavovce.java | 5 + .../src/com/company/creature/Bornable.java | 7 + .../src/com/company/creature/Creature.java | 13 ++ .../src/com/company/creature/Dieable.java | 7 + .../com/company/creature/MarineMammals.java | 51 ++++++ .../src/com/company/creature/Mucha.java | 23 +++ .../src/com/company/creature/birds/Bird.java | 52 ++++++ .../src/com/company/creature/birds/Eagle.java | 14 ++ .../src/com/company/creature/fish/Fish.java | 51 ++++++ .../src/com/company/creature/fish/Kapor.java | 15 ++ .../src/com/company/creature/fish/Nemo.java | 14 ++ .../creature/stavovcediely/Chrbtica.java | 13 ++ .../creature/stavovcediely/Stavec.java | 4 + .../creature/stavovcediely/Stavovec.java | 47 +++++ .../creature/stavovcediely/Sustava.java | 13 ++ .../creature/stavovcediely/TypSustavy.java | 12 ++ .../src/com/company/universe/Galaxy.java | 46 +++++ .../com/company/universe/PlanetaryNebula.java | 28 +++ .../src/com/company/universe/Universe.java | 40 ++++ 36 files changed, 1225 insertions(+) create mode 100644 MyFirstUniverseV2/.idea/description.html create mode 100644 MyFirstUniverseV2/.idea/discord.xml create mode 100644 MyFirstUniverseV2/.idea/encodings.xml create mode 100644 MyFirstUniverseV2/.idea/misc.xml create mode 100644 MyFirstUniverseV2/.idea/modules.xml create mode 100644 MyFirstUniverseV2/.idea/project-template.xml create mode 100644 MyFirstUniverseV2/.idea/uiDesigner.xml create mode 100644 MyFirstUniverseV2/.idea/vcs.xml create mode 100644 MyFirstUniverseV2/.idea/workspace.xml create mode 100644 MyFirstUniverseV2/MyFirstUniverse.iml create mode 100644 MyFirstUniverseV2/src/com/company/Main.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/CosmicBody.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/Earth.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/Planet.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/SolarSystem.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/Star.java create mode 100644 MyFirstUniverseV2/src/com/company/cosmicbody/Сomet.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/Bezstavovce.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/Bornable.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/Creature.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/Dieable.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/MarineMammals.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/Mucha.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/birds/Bird.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/birds/Eagle.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/fish/Fish.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/fish/Kapor.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/fish/Nemo.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/stavovcediely/Chrbtica.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavec.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavovec.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/stavovcediely/Sustava.java create mode 100644 MyFirstUniverseV2/src/com/company/creature/stavovcediely/TypSustavy.java create mode 100644 MyFirstUniverseV2/src/com/company/universe/Galaxy.java create mode 100644 MyFirstUniverseV2/src/com/company/universe/PlanetaryNebula.java create mode 100644 MyFirstUniverseV2/src/com/company/universe/Universe.java diff --git a/MyFirstUniverseV2/.idea/description.html b/MyFirstUniverseV2/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/MyFirstUniverseV2/.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/MyFirstUniverseV2/.idea/discord.xml b/MyFirstUniverseV2/.idea/discord.xml new file mode 100644 index 0000000..2a6a89a --- /dev/null +++ b/MyFirstUniverseV2/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/encodings.xml b/MyFirstUniverseV2/.idea/encodings.xml new file mode 100644 index 0000000..ab2dc53 --- /dev/null +++ b/MyFirstUniverseV2/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/misc.xml b/MyFirstUniverseV2/.idea/misc.xml new file mode 100644 index 0000000..7e211a1 --- /dev/null +++ b/MyFirstUniverseV2/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/modules.xml b/MyFirstUniverseV2/.idea/modules.xml new file mode 100644 index 0000000..774cf7c --- /dev/null +++ b/MyFirstUniverseV2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/project-template.xml b/MyFirstUniverseV2/.idea/project-template.xml new file mode 100644 index 0000000..d57a956 --- /dev/null +++ b/MyFirstUniverseV2/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/uiDesigner.xml b/MyFirstUniverseV2/.idea/uiDesigner.xml new file mode 100644 index 0000000..b93ac08 --- /dev/null +++ b/MyFirstUniverseV2/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/vcs.xml b/MyFirstUniverseV2/.idea/vcs.xml new file mode 100644 index 0000000..94f066c --- /dev/null +++ b/MyFirstUniverseV2/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/.idea/workspace.xml b/MyFirstUniverseV2/.idea/workspace.xml new file mode 100644 index 0000000..17bf568 --- /dev/null +++ b/MyFirstUniverseV2/.idea/workspace.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "D:/Study/3year/OOP/MyFirstUniverse", + "settings.editor.selected.configurable": "inlay.hints" + } +} + + + + + + + + + + + + + + 1664307490741 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/MyFirstUniverse.iml b/MyFirstUniverseV2/MyFirstUniverse.iml new file mode 100644 index 0000000..9465dd8 --- /dev/null +++ b/MyFirstUniverseV2/MyFirstUniverse.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyFirstUniverseV2/src/com/company/Main.java b/MyFirstUniverseV2/src/com/company/Main.java new file mode 100644 index 0000000..70a3c32 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/Main.java @@ -0,0 +1,144 @@ +package com.company; + +import com.company.cosmicbody.Earth; +import com.company.cosmicbody.Planet; +import com.company.cosmicbody.SolarSystem; +import com.company.cosmicbody.Star; +import com.company.creature.Creature; +import com.company.creature.MarineMammals; +import com.company.creature.Mucha; +import com.company.creature.birds.Eagle; +import com.company.creature.fish.Kapor; +import com.company.creature.fish.Nemo; +import com.company.universe.Galaxy; +import com.company.universe.PlanetaryNebula; +import com.company.universe.Universe; +import java.util.Date; + +public class Main { + + public static void main(String[] args) { + Universe myuniverse = new Universe(); + + System.out.println("\n"); + + 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); + + System.out.println("\n"); + + Planet Mercury = new Planet("Mercury", 1333, 6083, 0); + Planet Venus = new Planet("Venus", 4867, 938, 12.1); + //Planet Earth = new Planet("Earth", 100000, 108321); + Earth motherEarth = new Earth("Earth2", 100000, 108321); + Planet Mars = new Planet("Mars", 641, 16318, 9.81); + Planet Jupiter = new Planet("Jupiter", 3, 71313, 20.89); + Planet Saturn = new Planet("Saturn", 1000, 108408, 95.8); + Planet Uranus = new Planet("Uranus", 1000, 202156, 255.55); + Planet Neptune = new Planet("Neptune", 7050, 620654, 0); + + System.out.println("\n"); + + Star sun = new Star("Sun", 1.392, 1.40927, 1499726.85); + sun.on(); + + System.out.println("\n"); + + 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); + + System.out.println("\n"); + + Galaxy milkyWay = new Galaxy("Milky Way"); + milkyWay.addSustava(solarSystem); + + Galaxy Hryshchenko = new Galaxy("Hryshchenko"); + Hryshchenko.addSustava(solarSystem); + + System.out.println("\n"); + + milkyWay.sendMessage(Hryshchenko, "Hi, I'm you friend"); + Hryshchenko.sendMessage(milkyWay, "Hi."); + + System.out.println("\n"); + +// Creature Ara = new Bird("Blu", 60, 0.4, "Blu-ara"); +// Ara.move(10, 10, 20); +// Creature Ara1 = new Bird("Jewel", 55, 0.4, "Blu-ara"); +// Ara1.move(20,60,90); +// Creature Toucan = new Bird("Rafael", 65, 0.75, "Toco toucan"); +// Toucan.move(60,23,95); +// Creature Cardinal = new Bird("Pedro", 20, 0.09, "Red-crested cardinal"); +// Cardinal.move(98,65,32); +// Creature Canary = new Bird("Nico", 20.5, 0.05, "Domestic canary"); +// Canary.move(87,56,26); +// Creature Cockatoo = new Bird("Nigel", 55, 0.97, "Sulphur-crested cockatoo"); +// Cockatoo.move(95,45,12); +// Creature Toucan1 = new Bird("Eva", 53, 0.4, "Keel-billed toucan"); +// Toucan1.move(78,64,23); + + System.out.println("\n"); + +// Creature Clownfish = new Fish("Oscar" , 10, 0.02, "Bluestreak cleaner wrasse"); +// Clownfish.move(2000,9000,3000); +// Creature Shark = new Fish("Lenny" , 12000, 561, "Tiger shark"); +// Shark.move(6000,6258,82214); +// Creature Angelfish = new Fish("Angie" , 15, 0.06, "Angelfish"); +// Angelfish.move(8452,1235,7536); +// Creature Porcupinefish = new Fish("Sykes" , 91, 0.1, "Porcupinefish"); +// Porcupinefish.move(5628,7874,5632); +// Creature Lionfish = new Fish("Lola" , 45.7, 0.26, "Red lionfish"); +// Lionfish.move(6203,8954,8443); + + Kapor vianocnykapor = new Kapor(50); + Date dNow = new Date(); + vianocnykapor.born(dNow); + Earth earth = new Earth(); + earth.addCreature(vianocnykapor); + vianocnykapor.move(10,10,0); + vianocnykapor.die(dNow); + + earth.addCreature(new Nemo()); + earth.addCreature(new Eagle()); + + Mucha vinnamuska = new Mucha(); + earth.addCreature(vinnamuska); + + + + System.out.println("\n"); + + Creature Bear = new MarineMammals(); + Bear.move(56,9,0); + Creature Otter = new MarineMammals("Nora", 115.1, 3.6, "marine otter", true); + Otter.move(20,8,2); + Creature Walrus = new MarineMammals("Pupik", 4.4, 1700, "Walrus", true); + Walrus.move(35,58,8); + Creature Seals = new MarineMammals("Duska", 117.2, 45, "True seals", true); + Seals.move(9526,856,258); + + + + /*for(int i = 0; i < 2000; i++){ + motherEarth.addCreature(new Bird()); + motherEarth.addCreature(new Fish()); + } + + Creature[] array = motherEarth.getArrayCreature(); + for(int i = 0; i < 2000; i++){ + array[i].move(10,10,0); + }*/ + + System.out.println("\n"); + + myuniverse.stopUniverse(); + } +} \ No newline at end of file diff --git a/MyFirstUniverseV2/src/com/company/cosmicbody/CosmicBody.java b/MyFirstUniverseV2/src/com/company/cosmicbody/CosmicBody.java new file mode 100644 index 0000000..75edda2 --- /dev/null +++ b/MyFirstUniverseV2/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/MyFirstUniverseV2/src/com/company/cosmicbody/Earth.java b/MyFirstUniverseV2/src/com/company/cosmicbody/Earth.java new file mode 100644 index 0000000..5e89832 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/cosmicbody/Earth.java @@ -0,0 +1,27 @@ +package com.company.cosmicbody; + +import com.company.creature.Creature; + +public class Earth extends Planet{ + private Creature[] arrayCreature; + private int counterCreature; + + public Earth(String name, double weight, double diameter) { + super(name, weight, diameter); + + arrayCreature = new Creature[9999]; + counterCreature = 0; + } + + public void addCreature(Creature newCreature){ + arrayCreature[counterCreature] = newCreature; + counterCreature++; + } + + public Earth() { + } + + public Creature[] getArrayCreature() { + return arrayCreature; + } +} diff --git a/MyFirstUniverseV2/src/com/company/cosmicbody/Planet.java b/MyFirstUniverseV2/src/com/company/cosmicbody/Planet.java new file mode 100644 index 0000000..c309811 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/cosmicbody/Planet.java @@ -0,0 +1,106 @@ +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; + } + + public 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'm losing a lot of weight."); + } + if(Math.abs(this.weight-weight) > 1000){ + decreaseGravity(0.1); + } + } + 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); + } + } + + this.weight = weight; + } + + public double getDiameter() { + return diameter; + } + + public void setDiameter(double diameter) { + this.diameter = diameter; + } + + public String getName() { + return name; + } + + public 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; + System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation); + } + + 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; + System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation); + } + + public Planet() { + this.name = "Earth"; + this.weight = 5972200; + this.diameter = 12756; + System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation); + } + +} diff --git a/MyFirstUniverseV2/src/com/company/cosmicbody/SolarSystem.java b/MyFirstUniverseV2/src/com/company/cosmicbody/SolarSystem.java new file mode 100644 index 0000000..a600e25 --- /dev/null +++ b/MyFirstUniverseV2/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("Mars2", 432432, 432432); + objectCounter++; + + orbitalBody[objectCounter] = new Planet("Venusa2", 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/MyFirstUniverseV2/src/com/company/cosmicbody/Star.java b/MyFirstUniverseV2/src/com/company/cosmicbody/Star.java new file mode 100644 index 0000000..230ddfc --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/cosmicbody/Star.java @@ -0,0 +1,68 @@ +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; + System.out.println("Star is: " + name + " has been created. Parameters: " + weight + ", " + radius + ", " + temperature); + } + + public Star(){ + this.name = "naname"; + this.weight = 1000^35; + this.temperature = 500000; + System.out.println("Star is: " + name + " has been created"); + } + + public void on(){ + this.light = true; + this.temperature = temperature + 10000; + System.out.println("Status: on" + ". Temperature = " + temperature); + } + + public void off(){ + this.light = false; + this.temperature = temperature - 10000; + System.out.println("Status: off" + ". Temperature = " + temperature); + } + + 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/MyFirstUniverseV2/src/com/company/cosmicbody/Сomet.java b/MyFirstUniverseV2/src/com/company/cosmicbody/Сomet.java new file mode 100644 index 0000000..630946a --- /dev/null +++ b/MyFirstUniverseV2/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/MyFirstUniverseV2/src/com/company/creature/Bezstavovce.java b/MyFirstUniverseV2/src/com/company/creature/Bezstavovce.java new file mode 100644 index 0000000..9fbe450 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/Bezstavovce.java @@ -0,0 +1,5 @@ +package com.company.creature; + +public abstract class Bezstavovce extends Creature { + +} diff --git a/MyFirstUniverseV2/src/com/company/creature/Bornable.java b/MyFirstUniverseV2/src/com/company/creature/Bornable.java new file mode 100644 index 0000000..bf6adfa --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/Bornable.java @@ -0,0 +1,7 @@ +package com.company.creature; + +import java.util.Date; + +public interface Bornable { + public void born(Date DayOfBirth); +} diff --git a/MyFirstUniverseV2/src/com/company/creature/Creature.java b/MyFirstUniverseV2/src/com/company/creature/Creature.java new file mode 100644 index 0000000..a36b41a --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/Creature.java @@ -0,0 +1,13 @@ +package com.company.creature; + +import java.util.Date; + +public abstract class Creature implements Bornable, Dieable{ + protected Date DayOfBirth; + protected Date DayOfDie; + public abstract void move (int directionX, int directionY, int directionZ); + + public Date getDayOfBirth() { + return DayOfBirth; + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/Dieable.java b/MyFirstUniverseV2/src/com/company/creature/Dieable.java new file mode 100644 index 0000000..ab0b8ab --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/Dieable.java @@ -0,0 +1,7 @@ +package com.company.creature; + +import java.util.Date; + +public interface Dieable { + public void die(Date DayOfDie); +} diff --git a/MyFirstUniverseV2/src/com/company/creature/MarineMammals.java b/MyFirstUniverseV2/src/com/company/creature/MarineMammals.java new file mode 100644 index 0000000..e957e44 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/MarineMammals.java @@ -0,0 +1,51 @@ +package com.company.creature; + +import java.util.Date; + +public class MarineMammals extends Creature { + private String name; + private double height; + private double weight; + private String type; + private boolean predator = false; + + public MarineMammals(String name, double height, double weight, String type, boolean predator) { + this.name = name; + this.height = height; + this.weight = weight; + this.type = type; + this.predator = predator; + if (predator = true) { + System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: Yes" ); + }else{ + System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: No" ); + } + } + + public MarineMammals() { + this.name = "Umka"; + this.height = 222; + this.weight = 5555; + this.type = "White Bear"; + this.predator = false; + System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: " + this.predator); + } + + + + + @Override + public void move(int directionX, int directionY, int directionZ) { + System.out.println("I'm live in sea and land"); + } + + @Override + public void born(Date DayOfBirth) { + + } + + @Override + public void die(Date DayOfDie) { + + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/Mucha.java b/MyFirstUniverseV2/src/com/company/creature/Mucha.java new file mode 100644 index 0000000..f2af630 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/Mucha.java @@ -0,0 +1,23 @@ +package com.company.creature; + +import com.company.creature.Bezstavovce; + +import java.util.Date; + +public class Mucha extends Bezstavovce { + + @Override + public void born(Date DayOfBirth) { + + } + + @Override + public void move(int directionX, int directionY, int directionZ) { + + } + + @Override + public void die(Date DayOfDie) { + + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/birds/Bird.java b/MyFirstUniverseV2/src/com/company/creature/birds/Bird.java new file mode 100644 index 0000000..66f1424 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/birds/Bird.java @@ -0,0 +1,52 @@ +package com.company.creature.birds; + +import com.company.creature.stavovcediely.Stavovec; + +import java.util.Date; + +public abstract class Bird extends Stavovec { + private String name; + private double height; + private double weight; + private String type; + + public Bird(int pocet_stavcov){ + super(pocet_stavcov); + } + + public Bird(String name, double height, double weight, String type, int pocet_stavcov) { + super(pocet_stavcov); + this.name = name; + this.height = height; + this.weight = weight; + this.type = type; + System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type); + } + + public Bird() { + super(11); + this.name = "Loloska"; + this.height = 100; + this.weight = 10; + this.type = "parrot"; + System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type); + } + + + @Override + public void move(int directionX, int directionY, int directionZ) { + System.out.println("I fly. Because I'm bird"); + } + + @Override + public void born(Date DayOfBirth) { + super.DayOfBirth = DayOfBirth; + System.out.println("I was born " + super.DayOfBirth.toString()); + } + + @Override + public void die(Date DayOfDie) { + super.DayOfDie = DayOfDie; + System.out.println("I was die " + super.DayOfDie.toString()); + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/birds/Eagle.java b/MyFirstUniverseV2/src/com/company/creature/birds/Eagle.java new file mode 100644 index 0000000..9dbcb46 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/birds/Eagle.java @@ -0,0 +1,14 @@ +package com.company.creature.birds; + +public class Eagle extends Bird{ + public Eagle(int pocet_stavcov) { + super(pocet_stavcov); + } + + public Eagle(String name, double height, double weight, String type, int pocet_stavcov) { + super(name, height, weight, type, pocet_stavcov); + } + + public Eagle() { + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/fish/Fish.java b/MyFirstUniverseV2/src/com/company/creature/fish/Fish.java new file mode 100644 index 0000000..0726e98 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/fish/Fish.java @@ -0,0 +1,51 @@ +package com.company.creature.fish; + +import com.company.creature.stavovcediely.Stavovec; + +import java.util.Date; + +public abstract class Fish extends Stavovec { + private String name; + private double height; + private double weight; + private String type; + + public Fish(int pocet_stavcov){ + super(pocet_stavcov); + } + + public Fish(String name, double height, double weight, String type, int pocet_stavcov) { + super(pocet_stavcov); + this.name = name; + this.height = height; + this.weight = weight; + this.type = type; + System.out.println("Fish is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type); + } + + public Fish() { + super(11); + this.name = "Svoupy"; + this.height = 15; + this.weight = 0.2; + this.type = "Golden fish"; + System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type); + } + + @Override + public void move(int directionX, int directionY, int directionZ) { + System.out.println("I swim. Because I'm a fish"); + } + + @Override + public void born(Date DayOfBirth) { + super.DayOfBirth = DayOfBirth; + System.out.println("I was born " + super.DayOfBirth.toString()); + } + + @Override + public void die(Date DayOfDie) { + super.DayOfDie = DayOfDie; + System.out.println("I was die " + super.DayOfDie.toString()); + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/fish/Kapor.java b/MyFirstUniverseV2/src/com/company/creature/fish/Kapor.java new file mode 100644 index 0000000..3182239 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/fish/Kapor.java @@ -0,0 +1,15 @@ +package com.company.creature.fish; + +public class Kapor extends Fish{ + + public Kapor(int pocet_stavcov) { + super(pocet_stavcov); + } + + public Kapor(String name, double height, double weight, String type, int pocet_stavcov) { + super(name, height, weight, type, pocet_stavcov); + } + + public Kapor() { + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/fish/Nemo.java b/MyFirstUniverseV2/src/com/company/creature/fish/Nemo.java new file mode 100644 index 0000000..b498bf7 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/fish/Nemo.java @@ -0,0 +1,14 @@ +package com.company.creature.fish; + +public class Nemo extends Fish{ + public Nemo(int pocet_stavcov) { + super(pocet_stavcov); + } + + public Nemo(String name, double height, double weight, String type, int pocet_stavcov) { + super(name, height, weight, type, pocet_stavcov); + } + + public Nemo() { + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Chrbtica.java b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Chrbtica.java new file mode 100644 index 0000000..602f169 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Chrbtica.java @@ -0,0 +1,13 @@ +package com.company.creature.stavovcediely; + +public class Chrbtica { + private Stavec[] stavce; + + public Chrbtica(int pocet_stavcov) { + this.stavce = new Stavec[pocet_stavcov]; + } + + public Chrbtica() { + this.stavce = new Stavec[11]; + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavec.java b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavec.java new file mode 100644 index 0000000..1f2bc50 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavec.java @@ -0,0 +1,4 @@ +package com.company.creature.stavovcediely; + +public class Stavec { +} diff --git a/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavovec.java b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavovec.java new file mode 100644 index 0000000..b606376 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Stavovec.java @@ -0,0 +1,47 @@ +package com.company.creature.stavovcediely; + +import com.company.creature.Creature; + +import java.util.Date; + +public class Stavovec extends Creature { + + protected Chrbtica chrbtica; + protected Sustava[] sustavy; + + public Stavovec(int pocet_stavcov){ + chrbtica = new Chrbtica(pocet_stavcov); + } + + private void create_sustavy(){ + sustavy = new Sustava[8]; + + sustavy[0] = new Sustava(TypSustavy.OBEHOVA); + sustavy[1] = new Sustava(TypSustavy.OPOROVA); + sustavy[2] = new Sustava(TypSustavy.VYLUCOVACIA); + sustavy[3] = new Sustava(TypSustavy.POHYBOVA); + sustavy[4] = new Sustava(TypSustavy.DUCHACIA); + sustavy[5] = new Sustava(TypSustavy.TRAVIACA); + sustavy[6] = new Sustava(TypSustavy.ROZMNOZOVACIA); + sustavy[7] = new Sustava(TypSustavy.NEROVA); + } + + public Sustava[] getSustavy() { + return sustavy; + } + + @Override + public void born(Date DayOfBirth) { + + } + + @Override + public void move(int directionX, int directionY, int directionZ) { + + } + + @Override + public void die(Date DayOfDie) { + + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Sustava.java b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Sustava.java new file mode 100644 index 0000000..2dfef81 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/Sustava.java @@ -0,0 +1,13 @@ +package com.company.creature.stavovcediely; + +public class Sustava { + TypSustavy typSustavy; + + public Sustava(TypSustavy typSustavy) { + this.typSustavy = typSustavy; + } + + public void setTypSustavy(TypSustavy typSustavy) { + this.typSustavy = typSustavy; + } +} diff --git a/MyFirstUniverseV2/src/com/company/creature/stavovcediely/TypSustavy.java b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/TypSustavy.java new file mode 100644 index 0000000..26ecc16 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/creature/stavovcediely/TypSustavy.java @@ -0,0 +1,12 @@ +package com.company.creature.stavovcediely; + +public enum TypSustavy { + OPOROVA, + OBEHOVA, + VYLUCOVACIA, + POHYBOVA, + DUCHACIA, + TRAVIACA, + ROZMNOZOVACIA, + NEROVA +} diff --git a/MyFirstUniverseV2/src/com/company/universe/Galaxy.java b/MyFirstUniverseV2/src/com/company/universe/Galaxy.java new file mode 100644 index 0000000..ad3c1fc --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/universe/Galaxy.java @@ -0,0 +1,46 @@ +package com.company.universe; + +import com.company.cosmicbody.SolarSystem; + +public class Galaxy { + + private String name; + private SolarSystem[] systems = new SolarSystem[5000]; + private int objectCounter; + + private String message; + + public void sendMessage(Galaxy galaxy, String message){ + galaxy.setMessage(message); + System.out.println("Meassage: '" + message + "' from " + this.name + " has been send to: " + galaxy.name); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Galaxy(String name) { + this.name = name; + this.objectCounter = 0; + System.out.println("Galaxy is: " + name + " has been created."); + } + + + + 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/MyFirstUniverseV2/src/com/company/universe/PlanetaryNebula.java b/MyFirstUniverseV2/src/com/company/universe/PlanetaryNebula.java new file mode 100644 index 0000000..88de17d --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/universe/PlanetaryNebula.java @@ -0,0 +1,28 @@ +package com.company.universe; + +public class PlanetaryNebula { + + private String name; + private long size; + private long lifeDuration; + private long x, y , z; + + public PlanetaryNebula(){ + name = "myName"; + size = 0; + lifeDuration = 0; + x = 0; y = 0; z=0; + System.out.println("Created Planetary Nebula: " + name + "Parameters: " + lifeDuration + ", " + size + ". Coordination: " + x + ", " + y + ", " + z); + } + + 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; + System.out.println("Created Planetary Nebula: " + name + "Parameters: " + lifeDuration + ", " + size + ". Coordination: " + x + ", " + y + ", " + z); + } +} + diff --git a/MyFirstUniverseV2/src/com/company/universe/Universe.java b/MyFirstUniverseV2/src/com/company/universe/Universe.java new file mode 100644 index 0000000..3c4a176 --- /dev/null +++ b/MyFirstUniverseV2/src/com/company/universe/Universe.java @@ -0,0 +1,40 @@ +package com.company.universe; + +public class Universe { + private boolean state; + private long size; + + public Universe() { + state = false; + size = 0; + startUniverse(); + } + + public void startUniverse(){ + state = true; + System.out.println("World is ready"); + increaseSize(); + decreaseSize(10000); + } + + public void stopUniverse(){ + state = false; + System.out.println("World 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"); + } +}