Add files via upload

This commit is contained in:
1pablo10 2022-11-07 22:44:01 +01:00 committed by GitHub
parent 554bad2052
commit 4847eb094d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 230 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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");
}
}

View File

@ -0,0 +1,6 @@
package company.vesminetelesa;
public class Kometa extends Vesmirne_telesa{
private String name;
private double speed;
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}