diff --git a/company/vesminetelesa/Galaxia.java b/company/vesminetelesa/Galaxia.java new file mode 100644 index 0000000..9cc4ba7 --- /dev/null +++ b/company/vesminetelesa/Galaxia.java @@ -0,0 +1,15 @@ +package company.vesminetelesa; + +public class Galaxia extends Slnecna_sustava{ + private String name; + private Slnecna_sustava[] planetarne_sustavy = new Slnecna_sustava[1000]; + private int pocet_sustav; + + public void addSustava(Slnecna_sustava tato_sustava){ + planetarne_sustavy[pocet_sustav] = new Slnecna_sustava(); + } + + public Galaxia() { + pocet_sustav = 0; + } +} diff --git a/company/vesminetelesa/Hviezda.java b/company/vesminetelesa/Hviezda.java new file mode 100644 index 0000000..6670d3d --- /dev/null +++ b/company/vesminetelesa/Hviezda.java @@ -0,0 +1,60 @@ +package company.vesminetelesa; + +public class Hviezda extends Vesmirne_telesa { + private String name; + private double size; + private double age; + private Boolean svietim = false; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSize() { + return size; + } + + public void setSize(double size) { + this.size = size; + } + + public double getAge() { + return age; + } + + public void setAge(double age) { + this.age = age; + } + + public Hviezda() { + setType("Hviezda"); + setName("Hviezda Y"); + setSize(0); + setAge(0); + } + + public Hviezda(String name, double size, double age) { + setName(name); + setSize(size); + setAge(age); + setType("Hviezda"); + } + + public void sviet(){ + if(svietim == false){ + svietim = true; + } + else System.out.println("Uz svietim"); + } + + public void zhasni(){ + if(svietim == true){ + svietim = false; + } + else System.out.println("Uz som zhasnuta"); + } +} diff --git a/company/vesminetelesa/Kometa.java b/company/vesminetelesa/Kometa.java new file mode 100644 index 0000000..c137d3d --- /dev/null +++ b/company/vesminetelesa/Kometa.java @@ -0,0 +1,6 @@ +package company.vesminetelesa; + +public class Kometa extends Vesmirne_telesa{ + private String name; + private double speed; +} diff --git a/company/vesminetelesa/Planeta.java b/company/vesminetelesa/Planeta.java new file mode 100644 index 0000000..9f02e23 --- /dev/null +++ b/company/vesminetelesa/Planeta.java @@ -0,0 +1,91 @@ +package company.vesminetelesa; + +public class Planeta extends Vesmirne_telesa{ + private String name; + private double weight; + private double diameter; + private double gravity; + private Boolean weightSet=false; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getWeight() { + return weight; + } + + public void setWeight(double weight) { + if(this.weight > weight){ + if(this.weight-weight >= 1000){ + System.out.println("Ja chudnem"); + } + else System.out.println("Ja chudnem velmi"); + } + else if(this.weight < weight){ + if(this.weight-weight <= 1000){ + System.out.println("Dokelu pribrala som"); + } + else System.out.println("Velmo som pribrala"); + } + if((weight + 1000) < this.weight){ + decreaseGravity(0.1); + } + else if((weight-1000) > this.weight){ + increaseGravity(0.1); + } + this.weight = weight; + } + + public double getDiameter() { + return diameter; + } + + public void setDiameter(double diameter) { + this.diameter = diameter; + } + + public double getGravity() { + return gravity; + } + + public void setGravity(double gravity) { + this.gravity = gravity; + } + + public void increaseGravity(double add){ + setGravity(this.gravity+add); + } + + public void decreaseGravity(double dec){ + setGravity(this.gravity-dec); + } + + public void setPlanetaryWeight(double weight){ + if(weightSet == false){ + setWeight(this.weight+weight); + weightSet = true; + } + else System.out.println("Menit vahu mozes len raz"); + } + + public Planeta(String name, double weight, double diameter) { + setName(name); + setWeight(weight); + setDiameter(diameter); + } + + public Planeta(double gravity) { + setGravity(gravity); + } + + public Planeta() { + setName("Planeta X"); + setWeight(0); + setDiameter(0); + } +} \ No newline at end of file diff --git a/company/vesminetelesa/Slnecna_sustava.java b/company/vesminetelesa/Slnecna_sustava.java new file mode 100644 index 0000000..82442f8 --- /dev/null +++ b/company/vesminetelesa/Slnecna_sustava.java @@ -0,0 +1,45 @@ +package company.vesminetelesa; + +public class Slnecna_sustava { + private String name; + private Hviezda slnko; + private Vesmirne_telesa[] obezne_telesa = new Vesmirne_telesa[5000]; + private int object_counter; + + public int getObject_counter() { + return object_counter; + } + + public void setObject_counter(int object_counter) { + this.object_counter = object_counter; + } + + public Slnecna_sustava() { + slnko = new Hviezda(); + setObject_counter(0); + + String[] names = {"Merkur","Venusa","Zem","Mars","Jupiter","Saturn","Uran","Neptun"}; + double[] weights = {33022,48685,59736,64185,18986,56846,86810,10243}; + double[] diameters = {4879,12104,12742,6779,139820,116460,50724,49244}; + + for(int i=0;i<8;i++,object_counter++){ + obezne_telesa[object_counter] = new Planeta(names[i],weights[i],diameters[i]); + System.out.println("Nova planeta"); + } + obezne_telesa[object_counter] = new Hviezda("Slnko",696340,4603); + object_counter++; + } + + public void addTeleso(Vesmirne_telesa nove_teleso){ + obezne_telesa[object_counter]=nove_teleso; + object_counter++; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/company/vesminetelesa/Vesmirne_telesa.java b/company/vesminetelesa/Vesmirne_telesa.java new file mode 100644 index 0000000..8517ba3 --- /dev/null +++ b/company/vesminetelesa/Vesmirne_telesa.java @@ -0,0 +1,13 @@ +package company.vesminetelesa; + +public class Vesmirne_telesa { + public String type; + + public String getType() { + return type; + } + + protected void setType(String type) { + this.type = type; + } +}