This commit is contained in:
Oleksandr Hryshchenko 2022-11-29 23:09:03 +01:00
parent 943b5fe09b
commit 7eed6569c4
36 changed files with 1225 additions and 0 deletions

View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/MyFirstUniverse.iml" filepath="$PROJECT_DIR$/MyFirstUniverse.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

View 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitSharedSettings">
<option name="synchronizeBranchProtectionRules" value="false" />
</component>
</project>

View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="857763f3-a81c-449a-8888-ff5df6dee023" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="ADD_SUFFIX_TO_CHERRY_PICKS_OF_PUBLISHED_COMMITS" value="false" />
<option name="PREVIEW_PUSH_ON_COMMIT_AND_PUSH" value="false" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/svet" />
<option name="WARN_ABOUT_CRLF" value="false" />
<option name="WARN_ABOUT_DETACHED_HEAD" value="false" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2FMghcaH7Xgm9xQ0FjmXbPkGzmg" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1" splitterProportion="0.5">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="company" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
</panes>
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/Study/3year/OOP/MyFirstUniverse&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;inlay.hints&quot;
}
}</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
<option name="MAIN_CLASS_NAME" value="com.company.Main" />
<module name="MyFirstUniverse" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="857763f3-a81c-449a-8888-ff5df6dee023" name="Changes" comment="" />
<created>1664307490741</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1664307490741</updated>
<workItem from="1664307493533" duration="462000" />
<workItem from="1664954212249" duration="490000" />
<workItem from="1664955256543" duration="2938000" />
<workItem from="1664992953981" duration="2047000" />
<workItem from="1665396660524" duration="122000" />
<workItem from="1665529647566" duration="30000" />
<workItem from="1665559082986" duration="7912000" />
<workItem from="1665672593323" duration="70000" />
<workItem from="1666768705578" duration="4327000" />
<workItem from="1667733329462" duration="202000" />
<workItem from="1667742775449" duration="23000" />
<workItem from="1667751363182" duration="73000" />
<workItem from="1667751705366" duration="13759000" />
<workItem from="1667811885207" duration="7287000" />
<workItem from="1667824597894" duration="1941000" />
<workItem from="1667839107061" duration="895000" />
<workItem from="1667840376602" duration="3374000" />
<workItem from="1667858084425" duration="124000" />
<workItem from="1667858262314" duration="589000" />
<workItem from="1667858861369" duration="746000" />
<workItem from="1667900810467" duration="5122000" />
<workItem from="1667909850990" duration="1601000" />
<workItem from="1667978023696" duration="4691000" />
<workItem from="1669198101589" duration="513000" />
<workItem from="1669283031999" duration="278000" />
<workItem from="1669296857490" duration="9973000" />
<workItem from="1669746866999" duration="7685000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<ignored-roots>
<path value="$PROJECT_DIR$/svet" />
</ignored-roots>
</component>
</project>

View 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>

View File

@ -0,0 +1,144 @@
package com.company;
import com.company.cosmicbody.Earth;
import com.company.cosmicbody.Planet;
import com.company.cosmicbody.SolarSystem;
import com.company.cosmicbody.Star;
import com.company.creature.Creature;
import com.company.creature.MarineMammals;
import com.company.creature.Mucha;
import com.company.creature.birds.Eagle;
import com.company.creature.fish.Kapor;
import com.company.creature.fish.Nemo;
import com.company.universe.Galaxy;
import com.company.universe.PlanetaryNebula;
import com.company.universe.Universe;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Universe myuniverse = new Universe();
System.out.println("\n");
PlanetaryNebula Orion = new PlanetaryNebula("Orion",5, 18000,200,200,200);
PlanetaryNebula Buba = new PlanetaryNebula("Buba", 8, 2300, 12,59,94);
PlanetaryNebula Phonk = new PlanetaryNebula("Phonk", 20, 100000, 0,0,0);
System.out.println("\n");
Planet Mercury = new Planet("Mercury", 1333, 6083, 0);
Planet Venus = new Planet("Venus", 4867, 938, 12.1);
//Planet Earth = new Planet("Earth", 100000, 108321);
Earth motherEarth = new Earth("Earth2", 100000, 108321);
Planet Mars = new Planet("Mars", 641, 16318, 9.81);
Planet Jupiter = new Planet("Jupiter", 3, 71313, 20.89);
Planet Saturn = new Planet("Saturn", 1000, 108408, 95.8);
Planet Uranus = new Planet("Uranus", 1000, 202156, 255.55);
Planet Neptune = new Planet("Neptune", 7050, 620654, 0);
System.out.println("\n");
Star sun = new Star("Sun", 1.392, 1.40927, 1499726.85);
sun.on();
System.out.println("\n");
SolarSystem solarSystem = new SolarSystem();
solarSystem.addBody(Mercury);
solarSystem.addBody(Venus);
//solarSystem.addBody(Earth);
solarSystem.addBody(Mars);
solarSystem.addBody(Jupiter);
solarSystem.addBody(Saturn);
solarSystem.addBody(Uranus);
solarSystem.addBody(Neptune);
System.out.println("\n");
Galaxy milkyWay = new Galaxy("Milky Way");
milkyWay.addSustava(solarSystem);
Galaxy Hryshchenko = new Galaxy("Hryshchenko");
Hryshchenko.addSustava(solarSystem);
System.out.println("\n");
milkyWay.sendMessage(Hryshchenko, "Hi, I'm you friend");
Hryshchenko.sendMessage(milkyWay, "Hi.");
System.out.println("\n");
// Creature Ara = new Bird("Blu", 60, 0.4, "Blu-ara");
// Ara.move(10, 10, 20);
// Creature Ara1 = new Bird("Jewel", 55, 0.4, "Blu-ara");
// Ara1.move(20,60,90);
// Creature Toucan = new Bird("Rafael", 65, 0.75, "Toco toucan");
// Toucan.move(60,23,95);
// Creature Cardinal = new Bird("Pedro", 20, 0.09, "Red-crested cardinal");
// Cardinal.move(98,65,32);
// Creature Canary = new Bird("Nico", 20.5, 0.05, "Domestic canary");
// Canary.move(87,56,26);
// Creature Cockatoo = new Bird("Nigel", 55, 0.97, "Sulphur-crested cockatoo");
// Cockatoo.move(95,45,12);
// Creature Toucan1 = new Bird("Eva", 53, 0.4, "Keel-billed toucan");
// Toucan1.move(78,64,23);
System.out.println("\n");
// Creature Clownfish = new Fish("Oscar" , 10, 0.02, "Bluestreak cleaner wrasse");
// Clownfish.move(2000,9000,3000);
// Creature Shark = new Fish("Lenny" , 12000, 561, "Tiger shark");
// Shark.move(6000,6258,82214);
// Creature Angelfish = new Fish("Angie" , 15, 0.06, "Angelfish");
// Angelfish.move(8452,1235,7536);
// Creature Porcupinefish = new Fish("Sykes" , 91, 0.1, "Porcupinefish");
// Porcupinefish.move(5628,7874,5632);
// Creature Lionfish = new Fish("Lola" , 45.7, 0.26, "Red lionfish");
// Lionfish.move(6203,8954,8443);
Kapor vianocnykapor = new Kapor(50);
Date dNow = new Date();
vianocnykapor.born(dNow);
Earth earth = new Earth();
earth.addCreature(vianocnykapor);
vianocnykapor.move(10,10,0);
vianocnykapor.die(dNow);
earth.addCreature(new Nemo());
earth.addCreature(new Eagle());
Mucha vinnamuska = new Mucha();
earth.addCreature(vinnamuska);
System.out.println("\n");
Creature Bear = new MarineMammals();
Bear.move(56,9,0);
Creature Otter = new MarineMammals("Nora", 115.1, 3.6, "marine otter", true);
Otter.move(20,8,2);
Creature Walrus = new MarineMammals("Pupik", 4.4, 1700, "Walrus", true);
Walrus.move(35,58,8);
Creature Seals = new MarineMammals("Duska", 117.2, 45, "True seals", true);
Seals.move(9526,856,258);
/*for(int i = 0; i < 2000; i++){
motherEarth.addCreature(new Bird());
motherEarth.addCreature(new Fish());
}
Creature[] array = motherEarth.getArrayCreature();
for(int i = 0; i < 2000; i++){
array[i].move(10,10,0);
}*/
System.out.println("\n");
myuniverse.stopUniverse();
}
}

View File

@ -0,0 +1,13 @@
package com.company.cosmicbody;
public class CosmicBody {
private String body;
public String getBody() {
return body;
}
protected void setBody(String body) {
this.body = body;
}
}

View File

@ -0,0 +1,27 @@
package com.company.cosmicbody;
import com.company.creature.Creature;
public class Earth extends Planet{
private Creature[] arrayCreature;
private int counterCreature;
public Earth(String name, double weight, double diameter) {
super(name, weight, diameter);
arrayCreature = new Creature[9999];
counterCreature = 0;
}
public void addCreature(Creature newCreature){
arrayCreature[counterCreature] = newCreature;
counterCreature++;
}
public Earth() {
}
public Creature[] getArrayCreature() {
return arrayCreature;
}
}

View File

@ -0,0 +1,106 @@
package com.company.cosmicbody;
public class Planet extends CosmicBody {
private String name;
private double weight;
private double diameter;
private double gravitation;
private Boolean weightSet = false;
public void setPlanetaryWeight(double weight){
if(!weightSet){
setWeight(weight);
weightSet = true;
}
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
if(this.weight>weight){
if(Math.abs(this.weight-weight) <= 1000){
System.out.println("I'm losing weight.");
}
else {
System.out.println("I'm losing a lot of weight.");
}
if(Math.abs(this.weight-weight) > 1000){
decreaseGravity(0.1);
}
}
else{
if(Math.abs(this.weight-weight) <= 1000){
System.out.println("Damn, I woke up.");
}
else {
System.out.println("Damn, I put on too much weight.");
}
if(Math.abs(this.weight-weight) > 1000){
increaseGravity(0.1);
}
}
this.weight = weight;
}
public double getDiameter() {
return diameter;
}
public void setDiameter(double diameter) {
this.diameter = diameter;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getGravitation() {
return gravitation;
}
public void setGravitation(double gravitation) {
this.gravitation = gravitation;
}
public Planet(String name, double weight, double diameter) {
// setWeight(weight);
// setDiameter(diameter);
// setName(name);
this.name = name;
this.weight = weight;
this.diameter = diameter;
this.gravitation = 9.81;
System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation);
}
private void increaseGravity(double add){
gravitation = gravitation + add;
}
private void decreaseGravity(double dec){
gravitation = gravitation - dec;
}
public Planet(String name, double weight, double diameter, double gravitation) {
this.name = name;
this.weight = weight;
this.diameter = diameter;
this.gravitation = gravitation;
System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation);
}
public Planet() {
this.name = "Earth";
this.weight = 5972200;
this.diameter = 12756;
System.out.println("Planet is: " + name + " has been created. Parameters: " + weight + " " + diameter + ". Gravitation: " + gravitation);
}
}

View File

@ -0,0 +1,40 @@
package com.company.cosmicbody;
public class SolarSystem {
// private Star Sun = new Star();
// private Planet Earth;
// private Planet Mars;
// private Planet Jupiter;
// private Planet Saturn;
private CosmicBody[] orbitalBody = new CosmicBody[500000000];
private int objectCounter;
public SolarSystem() {
//star = new Star();
setObjectCounter(0);
orbitalBody[objectCounter] = new Planet("Mars2", 432432, 432432);
objectCounter++;
orbitalBody[objectCounter] = new Planet("Venusa2", 55, 32342);
objectCounter++;
orbitalBody[objectCounter] = new Star("Polar",0,0,0);
objectCounter++;
}
public void addBody(CosmicBody newBody){
orbitalBody[objectCounter] = newBody;
objectCounter++;
}
public int getObjectCounter() {
return objectCounter;
}
public void setObjectCounter(int objectCounter) {
this.objectCounter = objectCounter;
}
}

View File

@ -0,0 +1,68 @@
package com.company.cosmicbody;
public class Star extends CosmicBody {
private String name;
private double weight;
private double radius;
private double temperature;
private Boolean light = false;
public Star(String name, double weight, double radius, double temperature) {
this.name = name;
this.weight = weight;
this.radius = radius;
this.temperature = temperature;
System.out.println("Star is: " + name + " has been created. Parameters: " + weight + ", " + radius + ", " + temperature);
}
public Star(){
this.name = "naname";
this.weight = 1000^35;
this.temperature = 500000;
System.out.println("Star is: " + name + " has been created");
}
public void on(){
this.light = true;
this.temperature = temperature + 10000;
System.out.println("Status: on" + ". Temperature = " + temperature);
}
public void off(){
this.light = false;
this.temperature = temperature - 10000;
System.out.println("Status: off" + ". Temperature = " + temperature);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
}
}

View File

@ -0,0 +1,21 @@
package com.company.cosmicbody;
public class Сomet extends CosmicBody {
private int object_counter;
private CosmicBody[] orbitalBody = new CosmicBody[500000000];
public Сomet() {
setObject_counter(0);
orbitalBody[object_counter] = new Сomet();
object_counter++;
}
public int getObject_counter() {
return object_counter;
}
public void setObject_counter(int object_counter) {
this.object_counter = object_counter;
}
}

View File

@ -0,0 +1,5 @@
package com.company.creature;
public abstract class Bezstavovce extends Creature {
}

View File

@ -0,0 +1,7 @@
package com.company.creature;
import java.util.Date;
public interface Bornable {
public void born(Date DayOfBirth);
}

View File

@ -0,0 +1,13 @@
package com.company.creature;
import java.util.Date;
public abstract class Creature implements Bornable, Dieable{
protected Date DayOfBirth;
protected Date DayOfDie;
public abstract void move (int directionX, int directionY, int directionZ);
public Date getDayOfBirth() {
return DayOfBirth;
}
}

View File

@ -0,0 +1,7 @@
package com.company.creature;
import java.util.Date;
public interface Dieable {
public void die(Date DayOfDie);
}

View File

@ -0,0 +1,51 @@
package com.company.creature;
import java.util.Date;
public class MarineMammals extends Creature {
private String name;
private double height;
private double weight;
private String type;
private boolean predator = false;
public MarineMammals(String name, double height, double weight, String type, boolean predator) {
this.name = name;
this.height = height;
this.weight = weight;
this.type = type;
this.predator = predator;
if (predator = true) {
System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: Yes" );
}else{
System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: No" );
}
}
public MarineMammals() {
this.name = "Umka";
this.height = 222;
this.weight = 5555;
this.type = "White Bear";
this.predator = false;
System.out.println("Marine Mammals is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type + ". Predator: " + this.predator);
}
@Override
public void move(int directionX, int directionY, int directionZ) {
System.out.println("I'm live in sea and land");
}
@Override
public void born(Date DayOfBirth) {
}
@Override
public void die(Date DayOfDie) {
}
}

View File

@ -0,0 +1,23 @@
package com.company.creature;
import com.company.creature.Bezstavovce;
import java.util.Date;
public class Mucha extends Bezstavovce {
@Override
public void born(Date DayOfBirth) {
}
@Override
public void move(int directionX, int directionY, int directionZ) {
}
@Override
public void die(Date DayOfDie) {
}
}

View File

@ -0,0 +1,52 @@
package com.company.creature.birds;
import com.company.creature.stavovcediely.Stavovec;
import java.util.Date;
public abstract class Bird extends Stavovec {
private String name;
private double height;
private double weight;
private String type;
public Bird(int pocet_stavcov){
super(pocet_stavcov);
}
public Bird(String name, double height, double weight, String type, int pocet_stavcov) {
super(pocet_stavcov);
this.name = name;
this.height = height;
this.weight = weight;
this.type = type;
System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type);
}
public Bird() {
super(11);
this.name = "Loloska";
this.height = 100;
this.weight = 10;
this.type = "parrot";
System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type);
}
@Override
public void move(int directionX, int directionY, int directionZ) {
System.out.println("I fly. Because I'm bird");
}
@Override
public void born(Date DayOfBirth) {
super.DayOfBirth = DayOfBirth;
System.out.println("I was born " + super.DayOfBirth.toString());
}
@Override
public void die(Date DayOfDie) {
super.DayOfDie = DayOfDie;
System.out.println("I was die " + super.DayOfDie.toString());
}
}

View File

@ -0,0 +1,14 @@
package com.company.creature.birds;
public class Eagle extends Bird{
public Eagle(int pocet_stavcov) {
super(pocet_stavcov);
}
public Eagle(String name, double height, double weight, String type, int pocet_stavcov) {
super(name, height, weight, type, pocet_stavcov);
}
public Eagle() {
}
}

View File

@ -0,0 +1,51 @@
package com.company.creature.fish;
import com.company.creature.stavovcediely.Stavovec;
import java.util.Date;
public abstract class Fish extends Stavovec {
private String name;
private double height;
private double weight;
private String type;
public Fish(int pocet_stavcov){
super(pocet_stavcov);
}
public Fish(String name, double height, double weight, String type, int pocet_stavcov) {
super(pocet_stavcov);
this.name = name;
this.height = height;
this.weight = weight;
this.type = type;
System.out.println("Fish is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type);
}
public Fish() {
super(11);
this.name = "Svoupy";
this.height = 15;
this.weight = 0.2;
this.type = "Golden fish";
System.out.println("Bird is: " + name + " has been created. Parameters: " + height + "cm, " + weight + "kg. Type - " + type);
}
@Override
public void move(int directionX, int directionY, int directionZ) {
System.out.println("I swim. Because I'm a fish");
}
@Override
public void born(Date DayOfBirth) {
super.DayOfBirth = DayOfBirth;
System.out.println("I was born " + super.DayOfBirth.toString());
}
@Override
public void die(Date DayOfDie) {
super.DayOfDie = DayOfDie;
System.out.println("I was die " + super.DayOfDie.toString());
}
}

View File

@ -0,0 +1,15 @@
package com.company.creature.fish;
public class Kapor extends Fish{
public Kapor(int pocet_stavcov) {
super(pocet_stavcov);
}
public Kapor(String name, double height, double weight, String type, int pocet_stavcov) {
super(name, height, weight, type, pocet_stavcov);
}
public Kapor() {
}
}

View File

@ -0,0 +1,14 @@
package com.company.creature.fish;
public class Nemo extends Fish{
public Nemo(int pocet_stavcov) {
super(pocet_stavcov);
}
public Nemo(String name, double height, double weight, String type, int pocet_stavcov) {
super(name, height, weight, type, pocet_stavcov);
}
public Nemo() {
}
}

View File

@ -0,0 +1,13 @@
package com.company.creature.stavovcediely;
public class Chrbtica {
private Stavec[] stavce;
public Chrbtica(int pocet_stavcov) {
this.stavce = new Stavec[pocet_stavcov];
}
public Chrbtica() {
this.stavce = new Stavec[11];
}
}

View File

@ -0,0 +1,4 @@
package com.company.creature.stavovcediely;
public class Stavec {
}

View File

@ -0,0 +1,47 @@
package com.company.creature.stavovcediely;
import com.company.creature.Creature;
import java.util.Date;
public class Stavovec extends Creature {
protected Chrbtica chrbtica;
protected Sustava[] sustavy;
public Stavovec(int pocet_stavcov){
chrbtica = new Chrbtica(pocet_stavcov);
}
private void create_sustavy(){
sustavy = new Sustava[8];
sustavy[0] = new Sustava(TypSustavy.OBEHOVA);
sustavy[1] = new Sustava(TypSustavy.OPOROVA);
sustavy[2] = new Sustava(TypSustavy.VYLUCOVACIA);
sustavy[3] = new Sustava(TypSustavy.POHYBOVA);
sustavy[4] = new Sustava(TypSustavy.DUCHACIA);
sustavy[5] = new Sustava(TypSustavy.TRAVIACA);
sustavy[6] = new Sustava(TypSustavy.ROZMNOZOVACIA);
sustavy[7] = new Sustava(TypSustavy.NEROVA);
}
public Sustava[] getSustavy() {
return sustavy;
}
@Override
public void born(Date DayOfBirth) {
}
@Override
public void move(int directionX, int directionY, int directionZ) {
}
@Override
public void die(Date DayOfDie) {
}
}

View File

@ -0,0 +1,13 @@
package com.company.creature.stavovcediely;
public class Sustava {
TypSustavy typSustavy;
public Sustava(TypSustavy typSustavy) {
this.typSustavy = typSustavy;
}
public void setTypSustavy(TypSustavy typSustavy) {
this.typSustavy = typSustavy;
}
}

View File

@ -0,0 +1,12 @@
package com.company.creature.stavovcediely;
public enum TypSustavy {
OPOROVA,
OBEHOVA,
VYLUCOVACIA,
POHYBOVA,
DUCHACIA,
TRAVIACA,
ROZMNOZOVACIA,
NEROVA
}

View File

@ -0,0 +1,46 @@
package com.company.universe;
import com.company.cosmicbody.SolarSystem;
public class Galaxy {
private String name;
private SolarSystem[] systems = new SolarSystem[5000];
private int objectCounter;
private String message;
public void sendMessage(Galaxy galaxy, String message){
galaxy.setMessage(message);
System.out.println("Meassage: '" + message + "' from " + this.name + " has been send to: " + galaxy.name);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Galaxy(String name) {
this.name = name;
this.objectCounter = 0;
System.out.println("Galaxy is: " + name + " has been created.");
}
public void addSustava(SolarSystem system){
this.systems[objectCounter] = system;
this.setObjectCounter(this.objectCounter++);
}
public int getObjectCounter() {
return objectCounter;
}
private void setObjectCounter(int objectCounter) {
this.objectCounter = objectCounter;
}
}

View File

@ -0,0 +1,28 @@
package com.company.universe;
public class PlanetaryNebula {
private String name;
private long size;
private long lifeDuration;
private long x, y , z;
public PlanetaryNebula(){
name = "myName";
size = 0;
lifeDuration = 0;
x = 0; y = 0; z=0;
System.out.println("Created Planetary Nebula: " + name + "Parameters: " + lifeDuration + ", " + size + ". Coordination: " + x + ", " + y + ", " + z);
}
public PlanetaryNebula(String name,long lifeDuration, long size, long x, long y, long z) {
this.name = name;
this.lifeDuration = lifeDuration;
this.size = size;
this.x = x;
this.y = y;
this.z = z;
System.out.println("Created Planetary Nebula: " + name + "Parameters: " + lifeDuration + ", " + size + ". Coordination: " + x + ", " + y + ", " + z);
}
}

View File

@ -0,0 +1,40 @@
package com.company.universe;
public class Universe {
private boolean state;
private long size;
public Universe() {
state = false;
size = 0;
startUniverse();
}
public void startUniverse(){
state = true;
System.out.println("World is ready");
increaseSize();
decreaseSize(10000);
}
public void stopUniverse(){
state = false;
System.out.println("World is stop");
}
private void increaseSize(){
while (size<999000){
size++;
//System.out.println("Wait. Universe " + size + "km3");
}
System.out.println("Universe is " + size + "km3");
}
private void decreaseSize(long desiredSize){
while (size > desiredSize){
size--;
//System.out.println ("Wait. Compressed world " + size + "km3");
}
System.out.println ("Compress world is " + size + "km3");
}
}