First Commit
This commit is contained in:
commit
7e90ecde7d
29
.gitignore
vendored
Normal file
29
.gitignore
vendored
Normal file
@ -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
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="temurin-19" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/test2.iml" filepath="$PROJECT_DIR$/test2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
67
src/com/company/Galaxia.java
Normal file
67
src/com/company/Galaxia.java
Normal file
@ -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++;
|
||||
}
|
||||
}
|
26
src/com/company/Main.java
Normal file
26
src/com/company/Main.java
Normal file
@ -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());
|
||||
|
||||
|
||||
}
|
||||
}
|
68
src/com/company/Slnecna_sustava.java
Normal file
68
src/com/company/Slnecna_sustava.java
Normal file
@ -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++;
|
||||
}
|
||||
}
|
16
src/com/company/space/Nebula.java
Normal file
16
src/com/company/space/Nebula.java
Normal file
@ -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!");
|
||||
}
|
||||
}
|
53
src/com/company/space/Vesmir.java
Normal file
53
src/com/company/space/Vesmir.java
Normal file
@ -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³");
|
||||
}
|
||||
}
|
47
src/com/company/vesmirne_lodi/Mimozemska_lod.java
Normal file
47
src/com/company/vesmirne_lodi/Mimozemska_lod.java
Normal file
@ -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!!!");
|
||||
}
|
||||
}
|
30
src/com/company/vesmirne_lodi/lod.java
Normal file
30
src/com/company/vesmirne_lodi/lod.java
Normal file
@ -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!!!");
|
||||
}
|
||||
}
|
102
src/com/company/vesmirnetelesa/Hviezda.java
Normal file
102
src/com/company/vesmirnetelesa/Hviezda.java
Normal file
@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
23
src/com/company/vesmirnetelesa/Kometa.java
Normal file
23
src/com/company/vesmirnetelesa/Kometa.java
Normal file
@ -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");
|
||||
}
|
||||
|
||||
}
|
101
src/com/company/vesmirnetelesa/Planeta.java
Normal file
101
src/com/company/vesmirnetelesa/Planeta.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
44
src/com/company/vesmirnetelesa/Satelit.java
Normal file
44
src/com/company/vesmirnetelesa/Satelit.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
13
src/com/company/vesmirnetelesa/Vesmirne_teleso.java
Normal file
13
src/com/company/vesmirnetelesa/Vesmirne_teleso.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
11
test2.iml
Normal file
11
test2.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue
Block a user