This commit is contained in:
Oleksandr Hryshchenko 2022-12-14 00:34:48 +00:00
parent 383636534e
commit 461a402dc8

View File

@ -1,207 +1,211 @@
import com.company.Singletone; import com.company.Singletone;
import com.company.cars.Car; import com.company.cars.Car;
import com.company.cars.UniverseCarFactory; import com.company.cars.UniverseCarFactory;
import com.company.cosmicbody.Earth; import com.company.cosmicbody.Earth;
import com.company.cosmicbody.Planet; import com.company.cosmicbody.Planet;
import com.company.cosmicbody.SolarSystem; import com.company.cosmicbody.SolarSystem;
import com.company.cosmicbody.Star; import com.company.cosmicbody.Star;
import com.company.creature.Creature; import com.company.creature.Creature;
import com.company.creature.MarineMammals; import com.company.creature.MarineMammals;
import com.company.creature.Mucha; import com.company.creature.Mucha;
import com.company.creature.clovecina.Clovek; import com.company.creature.clovecina.Clovek;
import com.company.creature.clovecina.Muz; import com.company.creature.clovecina.Muz;
import com.company.creature.clovecina.Zena; import com.company.creature.clovecina.Zena;
import com.company.creature.stavovce.stavovcediely.birds.Eagle; import com.company.creature.stavovce.stavovcediely.birds.Eagle;
import com.company.creature.stavovce.stavovcediely.fish.Kapor; import com.company.creature.stavovce.stavovcediely.fish.Kapor;
import com.company.creature.stavovce.stavovcediely.fish.Nemo; import com.company.creature.stavovce.stavovcediely.fish.Nemo;
import com.company.universe.Galaxy; import com.company.universe.Galaxy;
import com.company.universe.PlanetaryNebula; import com.company.universe.PlanetaryNebula;
import com.company.universe.Universe; import com.company.universe.Universe;
import tools.MessageReader; import tools.MessageReader;
import tools.MessageWriter; import tools.MessageWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
Universe i_xander_i = new Universe(); Universe i_xander_i = new Universe();
System.out.println("\n"); System.out.println("\n");
PlanetaryNebula Orion = new PlanetaryNebula("Orion",5, 18000,200,200,200); PlanetaryNebula Orion = new PlanetaryNebula("Orion",5, 18000,200,200,200);
PlanetaryNebula Buba = new PlanetaryNebula("Buba", 8, 2300, 12,59,94); PlanetaryNebula Buba = new PlanetaryNebula("Buba", 8, 2300, 12,59,94);
PlanetaryNebula Phonk = new PlanetaryNebula("Phonk", 20, 100000, 0,0,0); PlanetaryNebula Phonk = new PlanetaryNebula("Phonk", 20, 100000, 0,0,0);
System.out.println("\n"); System.out.println("\n");
Planet Mercury = new Planet("Mercury", 1333, 6083, 0); Planet Mercury = new Planet("Mercury", 1333, 6083, 0);
Planet Venus = new Planet("Venus", 4867, 938, 12.1); Planet Venus = new Planet("Venus", 4867, 938, 12.1);
Planet Earth = new Planet("Earth", 100000, 108321); Planet Earth = new Planet("Earth", 100000, 108321);
Earth motherEarth = new Earth("Earth2", 100000, 108321); Earth motherEarth = new Earth("Earth2", 100000, 108321);
Planet Mars = new Planet("Mars", 641, 16318, 9.81); Planet Mars = new Planet("Mars", 641, 16318, 9.81);
Planet Jupiter = new Planet("Jupiter", 3, 71313, 20.89); Planet Jupiter = new Planet("Jupiter", 3, 71313, 20.89);
Planet Saturn = new Planet("Saturn", 1000, 108408, 95.8); Planet Saturn = new Planet("Saturn", 1000, 108408, 95.8);
Planet Uranus = new Planet("Uranus", 1000, 202156, 255.55); Planet Uranus = new Planet("Uranus", 1000, 202156, 255.55);
Planet Neptune = new Planet("Neptune", 7050, 620654, 0); Planet Neptune = new Planet("Neptune", 7050, 620654, 0);
System.out.println("\n"); System.out.println("\n");
Star sun = new Star("Sun", 1.392, 1.40927, 1499726.85); Star sun = new Star("Sun", 1.392, 1.40927, 1499726.85);
sun.on(); sun.on();
System.out.println("\n"); System.out.println("\n");
SolarSystem solarSystem = new SolarSystem(); SolarSystem solarSystem = new SolarSystem();
solarSystem.addBody(Mercury); solarSystem.addBody(Mercury);
solarSystem.addBody(Venus); solarSystem.addBody(Venus);
solarSystem.addBody(Earth); solarSystem.addBody(Earth);
solarSystem.addBody(Mars); solarSystem.addBody(Mars);
solarSystem.addBody(Jupiter); solarSystem.addBody(Jupiter);
solarSystem.addBody(Saturn); solarSystem.addBody(Saturn);
solarSystem.addBody(Uranus); solarSystem.addBody(Uranus);
solarSystem.addBody(Neptune); solarSystem.addBody(Neptune);
System.out.println("\n"); System.out.println("\n");
Galaxy milkyWay = new Galaxy("Milky Way"); Galaxy milkyWay = new Galaxy("Milky Way");
milkyWay.addSustava(solarSystem); milkyWay.addSustava(solarSystem);
Galaxy Hryshchenko = new Galaxy("Hryshchenko"); Galaxy Hryshchenko = new Galaxy("Hryshchenko");
Hryshchenko.addSustava(solarSystem); Hryshchenko.addSustava(solarSystem);
System.out.println("\n"); System.out.println("\n");
milkyWay.sendMessage(Hryshchenko, "Hi, I'm you friend"); milkyWay.sendMessage(Hryshchenko, "Hi, I'm you friend");
Hryshchenko.sendMessage(milkyWay, "Hi."); Hryshchenko.sendMessage(milkyWay, "Hi.");
System.out.println("\n"); System.out.println("\n");
/* Creature Ara = new Bird("Blu", 60, 0.4, "Blu-ara"); /* Creature Ara = new Bird("Blu", 60, 0.4, "Blu-ara");
Ara.move(10, 10, 20); Ara.move(10, 10, 20);
Creature Ara1 = new Bird("Jewel", 55, 0.4, "Blu-ara"); Creature Ara1 = new Bird("Jewel", 55, 0.4, "Blu-ara");
Ara1.move(20,60,90); Ara1.move(20,60,90);
Creature Toucan = new Bird("Rafael", 65, 0.75, "Toco toucan"); Creature Toucan = new Bird("Rafael", 65, 0.75, "Toco toucan");
Toucan.move(60,23,95); Toucan.move(60,23,95);
Creature Cardinal = new Bird("Pedro", 20, 0.09, "Red-crested cardinal"); Creature Cardinal = new Bird("Pedro", 20, 0.09, "Red-crested cardinal");
Cardinal.move(98,65,32); Cardinal.move(98,65,32);
Creature Canary = new Bird("Nico", 20.5, 0.05, "Domestic canary"); Creature Canary = new Bird("Nico", 20.5, 0.05, "Domestic canary");
Canary.move(87,56,26); Canary.move(87,56,26);
Creature Cockatoo = new Bird("Nigel", 55, 0.97, "Sulphur-crested cockatoo"); Creature Cockatoo = new Bird("Nigel", 55, 0.97, "Sulphur-crested cockatoo");
Cockatoo.move(95,45,12); Cockatoo.move(95,45,12);
Creature Toucan1 = new Bird("Eva", 53, 0.4, "Keel-billed toucan"); Creature Toucan1 = new Bird("Eva", 53, 0.4, "Keel-billed toucan");
Toucan1.move(78,64,23);*/ Toucan1.move(78,64,23);*/
/* System.out.println("\n"); /* System.out.println("\n");
Creature Clownfish = new Fish("Oscar" , 10, 0.02, "Bluestreak cleaner wrasse"); Creature Clownfish = new Fish("Oscar" , 10, 0.02, "Bluestreak cleaner wrasse");
Clownfish.move(2000,9000,3000); Clownfish.move(2000,9000,3000);
Creature Shark = new Fish("Lenny" , 12000, 561, "Tiger shark"); Creature Shark = new Fish("Lenny" , 12000, 561, "Tiger shark");
Shark.move(6000,6258,82214); Shark.move(6000,6258,82214);
Creature Angelfish = new Fish("Angie" , 15, 0.06, "Angelfish"); Creature Angelfish = new Fish("Angie" , 15, 0.06, "Angelfish");
Angelfish.move(8452,1235,7536); Angelfish.move(8452,1235,7536);
Creature Porcupinefish = new Fish("Sykes" , 91, 0.1, "Porcupinefish"); Creature Porcupinefish = new Fish("Sykes" , 91, 0.1, "Porcupinefish");
Porcupinefish.move(5628,7874,5632); Porcupinefish.move(5628,7874,5632);
Creature Lionfish = new Fish("Lola" , 45.7, 0.26, "Red lionfish"); Creature Lionfish = new Fish("Lola" , 45.7, 0.26, "Red lionfish");
Lionfish.move(6203,8954,8443);*/ Lionfish.move(6203,8954,8443);*/
Kapor vianocnykapor = new Kapor(50); Kapor vianocnykapor = new Kapor(50);
Date dNow = new Date(); Date dNow = new Date();
vianocnykapor.born(dNow); vianocnykapor.born(dNow);
motherEarth.addCreature(vianocnykapor); motherEarth.addCreature(vianocnykapor);
vianocnykapor.move(10,10,0); vianocnykapor.move(10,10,0);
vianocnykapor.die(dNow); vianocnykapor.die(dNow);
motherEarth.addCreature(new Nemo()); motherEarth.addCreature(new Nemo());
motherEarth.addCreature(new Eagle()); motherEarth.addCreature(new Eagle());
Mucha vinnamuska = new Mucha(); Mucha vinnamuska = new Mucha();
motherEarth.addCreature(vinnamuska); motherEarth.addCreature(vinnamuska);
System.out.println("\n"); System.out.println("\n");
Creature Bear = new MarineMammals(); Creature Bear = new MarineMammals();
Bear.move(56,9,0); Bear.move(56,9,0);
Creature Otter = new MarineMammals("Nora", 115.1, 3.6, "marine otter", true); Creature Otter = new MarineMammals("Nora", 115.1, 3.6, "marine otter", true);
Otter.move(20,8,2); Otter.move(20,8,2);
Creature Walrus = new MarineMammals("Pupik", 4.4, 1700, "Walrus", true); Creature Walrus = new MarineMammals("Pupik", 4.4, 1700, "Walrus", true);
Walrus.move(35,58,8); Walrus.move(35,58,8);
Creature Seals = new MarineMammals("Duska", 117.2, 45, "True seals", true); Creature Seals = new MarineMammals("Duska", 117.2, 45, "True seals", true);
Seals.move(9526,856,258); Seals.move(9526,856,258);
motherEarth.addCreature(Otter); motherEarth.addCreature(Otter);
motherEarth.addCreature(Bear); motherEarth.addCreature(Bear);
motherEarth.addCreature(Walrus); motherEarth.addCreature(Walrus);
motherEarth.addCreature(Seals); motherEarth.addCreature(Seals);
System.out.println("\n"); System.out.println("\n");
/*for(int i = 0; i < 2000; i++){ /*for(int i = 0; i < 2000; i++){
motherEarth.addCreature(new Bird()); motherEarth.addCreature(new Bird());
motherEarth.addCreature(new Fish()); motherEarth.addCreature(new Fish());
} }
Creature[] array = motherEarth.getArrayCreature(); Creature[] array = motherEarth.getArrayCreature();
for(int i = 0; i < 2000; i++){ for(int i = 0; i < 2000; i++){
array[i].move(10,10,0); array[i].move(10,10,0);
}*/ }*/
Muz prvyMuz = new Muz(null, null,34, "Adam", "Prvy"); Muz prvyMuz = new Muz(null, null,34, "Adam", "Prvy");
Zena prvaZena = new Zena(null, null,34, "Eva", "Prva"); Zena prvaZena = new Zena(null, null,34, "Eva", "Prva");
System.out.println(prvyMuz); System.out.println(prvyMuz);
System.out.println(prvaZena); System.out.println(prvaZena);
motherEarth.addCreature(prvyMuz); motherEarth.addCreature(prvyMuz);
motherEarth.addCreature(prvaZena); motherEarth.addCreature(prvaZena);
Clovek prvedieta = prvaZena.splodit(prvyMuz); Clovek prvedieta = prvaZena.splodit(prvyMuz);
prvedieta.born(dNow); prvedieta.born(dNow);
prvedieta.setName("Kain"); prvedieta.setName("Kain");
Clovek druhedieta = prvaZena.splodit(prvyMuz); Clovek druhedieta = prvaZena.splodit(prvyMuz);
druhedieta.born(dNow); druhedieta.born(dNow);
druhedieta.setName("Abel"); druhedieta.setName("Abel");
System.out.println(prvedieta); System.out.println(prvedieta);
System.out.println(druhedieta); System.out.println(druhedieta);
MessageReader AdamovReader = new MessageReader(); System.out.println("\n");
AdamovReader.obtainFilename(args);
AdamovReader.openAndRead(); MessageReader AdamovReader = new MessageReader();
AdamovReader.processMessage(); AdamovReader.obtainFilename(args);
AdamovReader.openAndRead();
MessageWriter AdamovWriter = new MessageWriter(motherEarth.getArrayCreature()); AdamovReader.processMessage();
AdamovWriter.WriteMessage();
MessageWriter AdamovWriter = new MessageWriter(motherEarth.getArrayCreature());
Singletone singletone = Singletone.getInstance(); AdamovWriter.WriteMessage();
singletone.takeUniverse(i_xander_i);
System.out.println("\n");
System.out.println("\n");
Singletone singletone = Singletone.getInstance();
UniverseCarFactory myFactory = new UniverseCarFactory("BMW"); singletone.takeUniverse(i_xander_i);
Car mvp = myFactory.produce("MVP"); System.out.println("\n");
Car suv = myFactory.produce("SUV");
Car sport = myFactory.produce("Sportcar"); UniverseCarFactory myFactory = new UniverseCarFactory("BMW");
Car little = myFactory.produce("Littlecar");
Car mvp = myFactory.produce("MVP");
System.out.println(mvp); Car suv = myFactory.produce("SUV");
System.out.println(suv); Car sport = myFactory.produce("Sportcar");
System.out.println(sport); Car little = myFactory.produce("Littlecar");
System.out.println(little);
System.out.println(mvp);
ArrayList<Car> warehouse = new ArrayList<Car>(); System.out.println(suv);
UniverseCarFactory Mercedes = new UniverseCarFactory("Mercedes"); System.out.println(sport);
UniverseCarFactory BMW = new UniverseCarFactory("BMW"); System.out.println(little);
for(int i =0; i<1000; i++ ){ ArrayList<Car> warehouse = new ArrayList<Car>();
Car mercedes = Mercedes.produce("Littlecar"); UniverseCarFactory Mercedes = new UniverseCarFactory("Mercedes");
Car bmw = BMW.produce("Sportcar"); UniverseCarFactory BMW = new UniverseCarFactory("BMW");
warehouse.add(mercedes);
warehouse.add(bmw); for(int i =0; i<1000; i++ ){
} Car mercedes = Mercedes.produce("Littlecar");
Car bmw = BMW.produce("Sportcar");
i_xander_i.stopUniverse(); warehouse.add(mercedes);
} warehouse.add(bmw);
}
i_xander_i.stopUniverse();
}
} }