commit 7e90ecde7de68f2504cf2ba45fda53eb4661f27f Author: Hellissheep Date: Sat Nov 2 17:31:01 2024 +0100 First Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..99321d4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2f87be9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/com/company/Galaxia.java b/src/com/company/Galaxia.java new file mode 100644 index 0000000..e2d90e0 --- /dev/null +++ b/src/com/company/Galaxia.java @@ -0,0 +1,67 @@ +package com.company; + +import com.company.vesmirnetelesa.Vesmirne_teleso; +import com.company.Slnecna_sustava; +import com.company.vesmirne_lodi.*; + +public class Galaxia { + public Slnecna_sustava[] sustavy = new Slnecna_sustava[100]; + private int counter_sustavy; + private String nazov; + public lod[] lodi = new lod[100]; + private int counter_lodi; + private String last_message; + + public String getLast_message() { + return last_message; + } + + public void setLast_message(String last_message) { + this.last_message = last_message; + System.out.println(last_message); + } + + public int getCounter_lodi() { + return counter_lodi; + } + + private void setCounter_lodi(int counter_lodi) { + this.counter_lodi = counter_lodi; + } + + public String getNazov() { + return nazov; + } + + public void setNazov(String nazov) { + this.nazov = nazov; + } + + public int getCounter_sustavy() { + return counter_sustavy; + } + + public void setCounter_sustavy(int counter_sustavy) { + this.counter_sustavy = counter_sustavy; + } + + public Galaxia(){ + setCounter_sustavy(0); + setNazov("Unknown"); + last_message = "No messages"; + } + public Galaxia(String name){ + setCounter_sustavy(0); + setNazov(name); + last_message = "No messages"; + } + + public void addSustava(Slnecna_sustava tato_sustava){ + sustavy[counter_sustavy] = tato_sustava; + counter_sustavy++; + } + public void addLod(lod tato_lod){ + lodi[counter_lodi] = tato_lod; + counter_lodi++; + } +} diff --git a/src/com/company/Main.java b/src/com/company/Main.java new file mode 100644 index 0000000..a3dee05 --- /dev/null +++ b/src/com/company/Main.java @@ -0,0 +1,26 @@ +package com.company; +import com.company.vesmirne_lodi.Mimozemska_lod; +import com.company.vesmirnetelesa.*; + + + + +public class Main { + public static void main(String[] args) { + Slnecna_sustava nasaSustava = new Slnecna_sustava("Naša sustava"); + + Galaxia MilkyWay = new Galaxia("MilkyWay"); + MilkyWay.addSustava(nasaSustava); + + MilkyWay.addLod(new Mimozemska_lod("Avrora", "Mars", 1300)); + MilkyWay.lodi[0].broadcastSosMessage(); + + Galaxia Korotkyy = new Galaxia("Korotkyy"); + + MilkyWay.lodi[0].broadcastSosMessage(Korotkyy); + + System.out.println("Korotkyy last message: " + Korotkyy.getLast_message()); + + + } +} \ No newline at end of file diff --git a/src/com/company/Slnecna_sustava.java b/src/com/company/Slnecna_sustava.java new file mode 100644 index 0000000..a1406f9 --- /dev/null +++ b/src/com/company/Slnecna_sustava.java @@ -0,0 +1,68 @@ +package com.company; + +import com.company.vesmirnetelesa.Hviezda; +import com.company.vesmirnetelesa.Planeta; +import com.company.vesmirnetelesa.Vesmirne_teleso; +import com.company.vesmirnetelesa.Kometa; + +public class Slnecna_sustava { + private Hviezda sun; + private String nazov; + public Vesmirne_teleso[] planets = new Vesmirne_teleso[500000000]; + public int object_counter; + + public String getNazov() { + return nazov; + } + + public void setNazov(String nazov) { + this.nazov = nazov; + } + + public int getObject_counter() { + return object_counter; + } + + public void setObject_counter(int object_counter) { + this.object_counter = object_counter; + } + + public Slnecna_sustava(){ + sun = new Hviezda(); + setNazov("Nova sustava"); + setObject_counter(0); + planets[object_counter]=new Planeta("Mars",432432,432432); + object_counter++; + planets[object_counter]= new Planeta("Venusa", 55555,32342); + object_counter++; + planets[object_counter]= new Hviezda("Polarka"); + object_counter++; + planets[object_counter]= new Kometa("Gojda"); + object_counter++; + planets[object_counter]= new Planeta("Zem", 432432,432432); + object_counter++; + } + + public Slnecna_sustava(String Name){ + sun = new Hviezda(); + setNazov(Name); + setObject_counter(0); + planets[object_counter]=new Planeta("Mars",432432,432432); + object_counter++; + planets[object_counter]= new Planeta("Venusa", 55555,32342); + object_counter++; + planets[object_counter]= new Hviezda("Polarka"); + object_counter++; + planets[object_counter]= new Kometa("Gojda"); + object_counter++; + planets[object_counter]= new Planeta("Zem", 432432,432432); + object_counter++; + + } + + public void addTeleso(Vesmirne_teleso nove_teleso) + { + planets[object_counter]=nove_teleso; + object_counter++; + } +} diff --git a/src/com/company/space/Nebula.java b/src/com/company/space/Nebula.java new file mode 100644 index 0000000..97f2e01 --- /dev/null +++ b/src/com/company/space/Nebula.java @@ -0,0 +1,16 @@ +package com.company.space; + +public class Nebula { + private long size; + private long age; + private int x, y, z; + + public Nebula(){ + size=0; + age=0; + x=0; + y=0; + z=0; + System.out.println("Wow im alive!"); + } +} diff --git a/src/com/company/space/Vesmir.java b/src/com/company/space/Vesmir.java new file mode 100644 index 0000000..4f562f1 --- /dev/null +++ b/src/com/company/space/Vesmir.java @@ -0,0 +1,53 @@ +package com.company.space; + +public class Vesmir { + private boolean state; + private long size; + + public Vesmir() { + state = false; + size=0; + } + + public void startVesmir(){ + state=true; + System.out.println("Vesmir nastartovany"); + + increaseSize(); + } + public void stopVesmir(){ + decreaseSize(0); + state=false; + System.out.println("Vesmir stoped"); + } + + private void increaseSize() { + if (state) { + while (size < 999_000) { + size++; + } + System.out.println("Velkost vesmiru dosiahla " + size + " tisíc km³"); + } else { + System.out.println("Vesmir nie je zapnutý, zväčšovanie nie je možné."); + } + } + private void decreaseSize(long desiredSize) { + if (!state) { // Проверяем, что вселенная включена + System.out.println("Vesmir nie je zapnutý, zmenšovanie nie je možné."); + return; + } + if (desiredSize < 0) { + System.out.println("Velkost vesmiru nemôže byť menšia ako 0."); + return; + } + if (desiredSize > size) { + System.out.println("Žiadna velkost je väčšia ako aktuálna velkost vesmiru."); + return; + } + + while (size > desiredSize) { + size--; + } + System.out.println("Velkost vesmiru dosiahla želanú velkost: " + desiredSize + " km³"); + } +} diff --git a/src/com/company/vesmirne_lodi/Mimozemska_lod.java b/src/com/company/vesmirne_lodi/Mimozemska_lod.java new file mode 100644 index 0000000..813aedf --- /dev/null +++ b/src/com/company/vesmirne_lodi/Mimozemska_lod.java @@ -0,0 +1,47 @@ +package com.company.vesmirne_lodi; + +import com.company.Galaxia; + +public class Mimozemska_lod extends lod{ + private String name; + private int speed; // km/h + + public Mimozemska_lod(String name, String planet, int speed) { + this.name = name; + setPlanet(planet); + this.speed = speed; + setType("Mimozemska lod"); + } + public Mimozemska_lod() { + this.name = "Unknown"; + setPlanet("Unknown"); + this.speed = 0; + setType("Mimozemska lod"); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + @Override + public void broadcastSosMessage(){ + System.out.println("[SOS] Lod " + this.name + " from planet " + getPlanet() + ": PLEASE HELP!!!"); + } + + @Override + public void broadcastSosMessage(Galaxia recipient){ + recipient.setLast_message("[SOS] Lod " + this.name + " from planet " + getPlanet() + ": PLEASE HELP!!!"); + } +} diff --git a/src/com/company/vesmirne_lodi/lod.java b/src/com/company/vesmirne_lodi/lod.java new file mode 100644 index 0000000..38010b3 --- /dev/null +++ b/src/com/company/vesmirne_lodi/lod.java @@ -0,0 +1,30 @@ +package com.company.vesmirne_lodi; + +import com.company.Galaxia; + +public class lod { + private String type; + private String planet; + + public String getType() { + return type; + } + + protected void setType(String type) { + this.type = type; + } + + public String getPlanet() { + return planet; + } + + protected void setPlanet(String planet) { + this.planet = planet; + } + public void broadcastSosMessage(){ + System.out.println("[SOS]: PLEASE HELP!!!"); + } + public void broadcastSosMessage(Galaxia recipient){ + recipient.setLast_message("[SOS]: PLEASE HELP!!!"); + } +} diff --git a/src/com/company/vesmirnetelesa/Hviezda.java b/src/com/company/vesmirnetelesa/Hviezda.java new file mode 100644 index 0000000..dea41ba --- /dev/null +++ b/src/com/company/vesmirnetelesa/Hviezda.java @@ -0,0 +1,102 @@ +package com.company.vesmirnetelesa; + +public class Hviezda extends Vesmirne_teleso{ + private String nazov; // názov hviezdy + private double hmotnost; // hmotnosť v kg (alebo násobkoch hmotnosti Slnka) + private double teplota; // teplota v Kelvinoch + private double povr_teplota; + private Boolean svietim; + + // Neparametrický konštruktor + public Hviezda() { + this.nazov = "Neznáma hviezda"; + this.hmotnost = 1.0; + this.teplota = 5778; + this.povr_teplota = 0; + this.svietim = false; + setType("Hviezda"); + } + + // Parametrický konštruktor + public Hviezda(String nazov, double hmotnost, double teplota) { + this.nazov = nazov; + this.hmotnost = hmotnost; + this.teplota = teplota; + this.svietim = false; + this.povr_teplota = 0; + setType("Hviezda"); + } + public Hviezda(String nazov) { + this.nazov = nazov; + this.hmotnost = 1.0; + this.teplota = 5778; + this.povr_teplota = 0; + this.svietim = false; + setType("Hviezda"); + } + + public double getPovr_teplota() { + return povr_teplota; + } + + public void setPovr_teplota(double povr_teplota) { + this.povr_teplota = povr_teplota; + } + + public String getNazov() { + return nazov; + } + + public void setNazov(String nazov) { + this.nazov = nazov; + } + + public double getHmotnost() { + return hmotnost; + } + + public void setHmotnost(double hmotnost) { + this.hmotnost = hmotnost; + } + + public double getTeplota() { + return teplota; + } + + public void setTeplota(double teplota) { + this.teplota = teplota; + } + + public double vypocitajZivotnost() { + return (Math.pow(10,10) / this.hmotnost); + } + + public void displayInfo() { + System.out.println("Star Name: " + nazov); + System.out.println("Mass: " + hmotnost + " solar masses"); + System.out.println("Temperature: " + teplota + " K"); + } + + public void sviet() { + if(!svietim) { + this.svietim = true; + setPovr_teplota(getTeplota()); + System.out.println(nazov + " teraz svieti s teplotou " + getPovr_teplota() + " K."); + } + else{ + System.out.println(nazov + " UZ svieti s teplotou " + getPovr_teplota() + " K."); + } + } + + public void zhasni() { + if(svietim) { + this.svietim = false; + setPovr_teplota(0); + System.out.println(nazov + " zhasla. Teplota: " + getPovr_teplota() + " K."); + } + else{ + System.out.println(nazov + " aj tak NE svieti!"); + } + } + +} diff --git a/src/com/company/vesmirnetelesa/Kometa.java b/src/com/company/vesmirnetelesa/Kometa.java new file mode 100644 index 0000000..b6ba549 --- /dev/null +++ b/src/com/company/vesmirnetelesa/Kometa.java @@ -0,0 +1,23 @@ +package com.company.vesmirnetelesa; + +public class Kometa extends Vesmirne_teleso{ + String nazov; + + public String getNazov() { + return nazov; + } + + public void setNazov(String nazov) { + this.nazov = nazov; + } + + public Kometa(){ + setNazov("Unknown"); + setType("Kometa"); + } + public Kometa(String name){ + setNazov(name); + setType("Kometa"); + } + +} diff --git a/src/com/company/vesmirnetelesa/Planeta.java b/src/com/company/vesmirnetelesa/Planeta.java new file mode 100644 index 0000000..bc4dceb --- /dev/null +++ b/src/com/company/vesmirnetelesa/Planeta.java @@ -0,0 +1,101 @@ +package com.company.vesmirnetelesa; + +public class Planeta extends Vesmirne_teleso { + private double vaha; + private double priemer; + private String name; + private double gravitacia; + private Boolean weightSet = false; + + public Planeta(String name, double vaha, double priemer){ + this.vaha = vaha; + setPriemer(priemer); + setName(name); + setGravitacia(9.81); + setType("Planeta"); + } + + public Planeta(String name,double vaha, double priemer, double g){ + this.vaha = vaha; + setPriemer(priemer); + setName(name); + setGravitacia(g); + setType("Planeta"); + } + public Planeta(){ + this.vaha = 5972200; + setPriemer(12756); + setName("Planeta"); + setGravitacia(9.81); + setType("Planeta"); + } + + public double getGravitacia() { + return gravitacia; + } + + public void setGravitacia(double gravitacia) { + this.gravitacia = gravitacia; + } + + public void increaseGravity(double add) { + this.gravitacia += add; + System.out.println("Gravitácia sa zvýšila o " + add + ". Nová gravitácia: " + this.gravitacia); + } + + public void decreaseGravity(double dec) { + this.gravitacia -= dec; + System.out.println("Gravitácia sa znížila o " + dec + ". Nová gravitácia: " + this.gravitacia); + } + + public double getVaha() { + return vaha; + } + + public void setVaha(double vaha) { + double rozdiel = Math.abs(getVaha() - vaha); + + if (getVaha() > vaha) { // Váha sa znížila (chudne) + if (rozdiel <= 1000) { + System.out.println("Ja chudnem."); + } else { + System.out.println("Ja chudnem veľmi."); + decreaseGravity(0.1); + } + } else { + if (rozdiel <= 1000) { + System.out.println("Dokelu, pribrala som."); + } else { + System.out.println("Sakra, moooc som pribrala."); + increaseGravity(0.1); + } + } + this.vaha = vaha; + } + + public String getName() { + return name; + } + + private void setName(String name) { + this.name = name; + } + + public double getPriemer() { + return priemer; + } + + private void setPriemer(double priemer) { + this.priemer = priemer; + } + + public void setPlanetaryWeight(double vaha){ + if (!weightSet){ + setVaha(vaha); + weightSet = true; + System.out.println("Vaha seted: " + getVaha()); + } + else + System.out.println("Vaha už seted"); + } +} diff --git a/src/com/company/vesmirnetelesa/Satelit.java b/src/com/company/vesmirnetelesa/Satelit.java new file mode 100644 index 0000000..0087663 --- /dev/null +++ b/src/com/company/vesmirnetelesa/Satelit.java @@ -0,0 +1,44 @@ +package com.company.vesmirnetelesa; + +public class Satelit extends Vesmirne_teleso{ + private String name; + private String country; + private int speed; // km/h + + public Satelit(String name, String country, int speed) { + this.name = name; + this.country = country; + this.speed = speed; + setType("Satelit"); + } + public Satelit() { + this.name = "Unknown"; + this.country = "Unknown"; + this.speed = 0; + setType("Satelit"); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } +} diff --git a/src/com/company/vesmirnetelesa/Vesmirne_teleso.java b/src/com/company/vesmirnetelesa/Vesmirne_teleso.java new file mode 100644 index 0000000..4672229 --- /dev/null +++ b/src/com/company/vesmirnetelesa/Vesmirne_teleso.java @@ -0,0 +1,13 @@ +package com.company.vesmirnetelesa; + +public class Vesmirne_teleso { + private String type; + + public String getType() { + return type; + } + + protected void setType(String type) { + this.type = type; + } +} diff --git a/test2.iml b/test2.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/test2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file