DU3 complete
This commit is contained in:
parent
7e90ecde7d
commit
04d97dc938
@ -1,26 +1,38 @@
|
|||||||
package com.company;
|
package com.company;
|
||||||
import com.company.vesmirne_lodi.Mimozemska_lod;
|
|
||||||
import com.company.vesmirnetelesa.*;
|
import com.company.vesmirnetelesa.Planeta;
|
||||||
|
import com.company.vesmirnetelesa.Zem;
|
||||||
|
import com.company.zive_tvory.Tvor;
|
||||||
|
import com.company.zive_tvory.ryby.Kapor;
|
||||||
|
import com.company.zive_tvory.ryby.Losos;
|
||||||
|
import com.company.zive_tvory.ryby.Ryba;
|
||||||
|
import com.company.zive_tvory.vtaky.Orel;
|
||||||
|
import com.company.zive_tvory.vtaky.Vtak;
|
||||||
|
import com.company.zive_tvory.hmyz.Mucha;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
public class Main{
|
||||||
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Slnecna_sustava nasaSustava = new Slnecna_sustava("Naša sustava");
|
Zem zem = new Zem();
|
||||||
|
Kapor vianocnykapor = new Kapor(50);
|
||||||
|
Losos losos = new Losos(40);
|
||||||
|
Orel orel = new Orel(30);
|
||||||
|
Mucha mucha = new Mucha();
|
||||||
|
Date dNow = new Date();
|
||||||
|
|
||||||
Galaxia MilkyWay = new Galaxia("MilkyWay");
|
vianocnykapor.born(dNow);
|
||||||
MilkyWay.addSustava(nasaSustava);
|
zem.addTvor(vianocnykapor);
|
||||||
|
zem.addTvor(losos);
|
||||||
MilkyWay.addLod(new Mimozemska_lod("Avrora", "Mars", 1300));
|
zem.addTvor(orel);
|
||||||
MilkyWay.lodi[0].broadcastSosMessage();
|
zem.addTvor(mucha);
|
||||||
|
vianocnykapor.hybsa(10, 10, 0);
|
||||||
Galaxia Korotkyy = new Galaxia("Korotkyy");
|
vianocnykapor.die(new Date());
|
||||||
|
|
||||||
MilkyWay.lodi[0].broadcastSosMessage(Korotkyy);
|
|
||||||
|
|
||||||
System.out.println("Korotkyy last message: " + Korotkyy.getLast_message());
|
|
||||||
|
|
||||||
|
System.out.println("Vianocny kapor sa narodil " + vianocnykapor.getDate_of_birth());
|
||||||
|
|
||||||
|
for (int i = 0; i < vianocnykapor.getSustavy().length; i++) {
|
||||||
|
System.out.println(vianocnykapor.getSustavy()[i].getTypSustavy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
44
src/com/company/vesmirnetelesa/Zem.java
Normal file
44
src/com/company/vesmirnetelesa/Zem.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package com.company.vesmirnetelesa;
|
||||||
|
import com.company.zive_tvory.Tvor;
|
||||||
|
|
||||||
|
public class Zem extends Planeta {
|
||||||
|
|
||||||
|
private Tvor[] poleTvorov;
|
||||||
|
private int tvorovCount;
|
||||||
|
|
||||||
|
public Zem() {
|
||||||
|
super("Zem", 5972200, 12756, 9.81);
|
||||||
|
this.poleTvorov = new Tvor[100];
|
||||||
|
this.tvorovCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Zem(double vaha, double priemer) {
|
||||||
|
super("Zem", vaha, priemer, 9.81);
|
||||||
|
this.poleTvorov = new Tvor[100];
|
||||||
|
this.tvorovCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Zem(double vaha, double priemer, double gravitacia) {
|
||||||
|
super("Zem", vaha, priemer, gravitacia);
|
||||||
|
this.poleTvorov = new Tvor[100];
|
||||||
|
this.tvorovCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Метод для добавления создания в массив
|
||||||
|
public void addTvor(Tvor tvor) {
|
||||||
|
if (tvorovCount < poleTvorov.length) {
|
||||||
|
poleTvorov[tvorovCount++] = tvor;
|
||||||
|
System.out.println("A creature has been added to Earth.");
|
||||||
|
} else {
|
||||||
|
System.out.println("No space left for more creatures.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Дополнительный метод для вывода информации о всех созданиях
|
||||||
|
public void displayCreatures() {
|
||||||
|
System.out.println("Displaying all creatures on Earth:");
|
||||||
|
for (int i = 0; i < tvorovCount; i++) {
|
||||||
|
System.out.println("Creature " + (i + 1) + ": " + poleTvorov[i].getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/com/company/zive_tvory/Bezstavovce.java
Normal file
7
src/com/company/zive_tvory/Bezstavovce.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory;
|
||||||
|
|
||||||
|
public abstract class Bezstavovce extends Tvor {
|
||||||
|
public Bezstavovce() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
32
src/com/company/zive_tvory/Stavovec.java
Normal file
32
src/com/company/zive_tvory/Stavovec.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.company.zive_tvory;
|
||||||
|
|
||||||
|
import com.company.zive_tvory.stavovce_diely.Chrbtica;
|
||||||
|
import com.company.zive_tvory.stavovce_diely.Stavec;
|
||||||
|
import com.company.zive_tvory.stavovce_diely.Sustava;
|
||||||
|
import com.company.zive_tvory.stavovce_diely.Typ_sustavy;
|
||||||
|
|
||||||
|
public abstract class Stavovec extends Tvor{
|
||||||
|
protected Chrbtica chrbtica;
|
||||||
|
protected Sustava[] sustavy;
|
||||||
|
public Stavovec(int pocet_stavcoc){
|
||||||
|
chrbtica = new Chrbtica(pocet_stavcoc);
|
||||||
|
create_sustavy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create_sustavy() {
|
||||||
|
sustavy = new Sustava[8];
|
||||||
|
|
||||||
|
sustavy[0] = new Sustava(Typ_sustavy.OBEHOVA);
|
||||||
|
sustavy[1] = new Sustava(Typ_sustavy.OPORNA);
|
||||||
|
sustavy[2] = new Sustava(Typ_sustavy.VYLUCOVACIA);
|
||||||
|
sustavy[3] = new Sustava(Typ_sustavy.POHYBOVA);
|
||||||
|
sustavy[4] = new Sustava(Typ_sustavy.DYCHACIA);
|
||||||
|
sustavy[5] = new Sustava(Typ_sustavy.TRAVIACA);
|
||||||
|
sustavy[6] = new Sustava(Typ_sustavy.ROZMNOZOVACIA);
|
||||||
|
sustavy[7] = new Sustava(Typ_sustavy.NERVOVA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sustava[] getSustavy() {
|
||||||
|
return sustavy;
|
||||||
|
}
|
||||||
|
}
|
17
src/com/company/zive_tvory/Tvor.java
Normal file
17
src/com/company/zive_tvory/Tvor.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.zive_tvory;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class Tvor implements bornable, dieable{
|
||||||
|
protected Date date_of_birth;
|
||||||
|
protected Date date_of_death;
|
||||||
|
|
||||||
|
public abstract void hybsa(int directionX, int directionY, int directionZ);
|
||||||
|
|
||||||
|
public Date getDate_of_birth() {
|
||||||
|
return date_of_birth;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7
src/com/company/zive_tvory/bornable.java
Normal file
7
src/com/company/zive_tvory/bornable.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface bornable {
|
||||||
|
public void born(Date day_of_birth);
|
||||||
|
}
|
7
src/com/company/zive_tvory/dieable.java
Normal file
7
src/com/company/zive_tvory/dieable.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public interface dieable {
|
||||||
|
public void die(Date day_of_death);
|
||||||
|
}
|
26
src/com/company/zive_tvory/hmyz/Hmyz.java
Normal file
26
src/com/company/zive_tvory/hmyz/Hmyz.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package com.company.zive_tvory.hmyz;
|
||||||
|
|
||||||
|
import com.company.zive_tvory.Bezstavovce;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public abstract class Hmyz extends Bezstavovce {
|
||||||
|
public Hmyz() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hybsa(int directionX, int directionY, int directionZ) {
|
||||||
|
System.out.println("I am flying in directions: " + directionX + ", " + directionY + ", " + directionZ);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void born(Date day_of_birth){
|
||||||
|
super.date_of_birth=day_of_birth;
|
||||||
|
System.out.println("I was born on" + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void die(Date day_of_death){
|
||||||
|
super.date_of_death=day_of_death;
|
||||||
|
System.out.println("I died on " + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
}
|
7
src/com/company/zive_tvory/hmyz/Mucha.java
Normal file
7
src/com/company/zive_tvory/hmyz/Mucha.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory.hmyz;
|
||||||
|
|
||||||
|
public class Mucha extends Hmyz {
|
||||||
|
public Mucha() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
7
src/com/company/zive_tvory/ryby/Kapor.java
Normal file
7
src/com/company/zive_tvory/ryby/Kapor.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory.ryby;
|
||||||
|
|
||||||
|
public class Kapor extends Ryba{
|
||||||
|
public Kapor(int pocet_stavcov){
|
||||||
|
super(pocet_stavcov);
|
||||||
|
}
|
||||||
|
}
|
7
src/com/company/zive_tvory/ryby/Losos.java
Normal file
7
src/com/company/zive_tvory/ryby/Losos.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory.ryby;
|
||||||
|
|
||||||
|
public class Losos extends Ryba {
|
||||||
|
public Losos(int pocet_stavcov){
|
||||||
|
super(pocet_stavcov);
|
||||||
|
}
|
||||||
|
}
|
27
src/com/company/zive_tvory/ryby/Ryba.java
Normal file
27
src/com/company/zive_tvory/ryby/Ryba.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.company.zive_tvory.ryby;
|
||||||
|
|
||||||
|
import com.company.zive_tvory.Stavovec;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public abstract class Ryba extends Stavovec {
|
||||||
|
|
||||||
|
public Ryba(int pocet_stavcoc){
|
||||||
|
super(pocet_stavcoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hybsa(int directionX, int directionY, int directionZ) {
|
||||||
|
System.out.println("The fish is swimming in directions: " + directionX + ", " + directionY + ", " + directionZ);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void born(Date day_of_birth){
|
||||||
|
super.date_of_birth=day_of_birth;
|
||||||
|
System.out.println("I was born on " + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void die(Date day_of_death){
|
||||||
|
super.date_of_death=day_of_death;
|
||||||
|
System.out.println("I died on " + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
}
|
18
src/com/company/zive_tvory/stavovce_diely/Chrbtica.java
Normal file
18
src/com/company/zive_tvory/stavovce_diely/Chrbtica.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.company.zive_tvory.stavovce_diely;
|
||||||
|
|
||||||
|
public class Chrbtica {
|
||||||
|
|
||||||
|
private Stavec[] stavce; // Массив для хранения позвонков
|
||||||
|
|
||||||
|
public Chrbtica(int pocetStavcov) {
|
||||||
|
this.stavce = new Stavec[pocetStavcov]; // Создаем массив с заданным количеством позвонков
|
||||||
|
for (int i = 0; i < pocetStavcov; i++) {
|
||||||
|
stavce[i] = new Stavec(); // Заполняем массив экземплярами Stavec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Метод для получения количества позвонков
|
||||||
|
public int getPocetStavcov() {
|
||||||
|
return stavce.length;
|
||||||
|
}
|
||||||
|
}
|
4
src/com/company/zive_tvory/stavovce_diely/Stavec.java
Normal file
4
src/com/company/zive_tvory/stavovce_diely/Stavec.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package com.company.zive_tvory.stavovce_diely;
|
||||||
|
|
||||||
|
public class Stavec {
|
||||||
|
}
|
14
src/com/company/zive_tvory/stavovce_diely/Sustava.java
Normal file
14
src/com/company/zive_tvory/stavovce_diely/Sustava.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.company.zive_tvory.stavovce_diely;
|
||||||
|
|
||||||
|
public class Sustava {
|
||||||
|
Typ_sustavy typSustavy; // typ sústavy - jedna z obehová/oporná/vylučovacia ...
|
||||||
|
|
||||||
|
// konštruktor triedy sústava
|
||||||
|
public Sustava(Typ_sustavy typSustavy) {
|
||||||
|
this.typSustavy = typSustavy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Typ_sustavy getTypSustavy() {
|
||||||
|
return typSustavy;
|
||||||
|
}
|
||||||
|
}
|
12
src/com/company/zive_tvory/stavovce_diely/Typ_sustavy.java
Normal file
12
src/com/company/zive_tvory/stavovce_diely/Typ_sustavy.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.company.zive_tvory.stavovce_diely;
|
||||||
|
|
||||||
|
public enum Typ_sustavy {
|
||||||
|
OPORNA,
|
||||||
|
OBEHOVA,
|
||||||
|
VYLUCOVACIA,
|
||||||
|
POHYBOVA,
|
||||||
|
DYCHACIA,
|
||||||
|
TRAVIACA,
|
||||||
|
ROZMNOZOVACIA,
|
||||||
|
NERVOVA
|
||||||
|
}
|
7
src/com/company/zive_tvory/vtaky/Orel.java
Normal file
7
src/com/company/zive_tvory/vtaky/Orel.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.company.zive_tvory.vtaky;
|
||||||
|
|
||||||
|
public class Orel extends Vtak {
|
||||||
|
public Orel(int pocet_stavcov){
|
||||||
|
super(pocet_stavcov);
|
||||||
|
}
|
||||||
|
}
|
27
src/com/company/zive_tvory/vtaky/Vtak.java
Normal file
27
src/com/company/zive_tvory/vtaky/Vtak.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.company.zive_tvory.vtaky;
|
||||||
|
|
||||||
|
import com.company.zive_tvory.Stavovec;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public abstract class Vtak extends Stavovec {
|
||||||
|
|
||||||
|
public Vtak(int pocet_stavcov){
|
||||||
|
super(pocet_stavcov);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hybsa(int directionX, int directionY, int directionZ) {
|
||||||
|
System.out.println("I am flying in directions: " + directionX + ", " + directionY + ", " + directionZ);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void born(Date day_of_birth){
|
||||||
|
super.date_of_birth=day_of_birth;
|
||||||
|
System.out.println("I was born on" + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void die(Date day_of_death){
|
||||||
|
super.date_of_death=day_of_death;
|
||||||
|
System.out.println("I died on " + super.date_of_birth.toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user