Lab 5
This commit is contained in:
commit
a82aa282a0
|
@ -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
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Lab5.iml" filepath="$PROJECT_DIR$/Lab5.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -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>
|
|
@ -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>
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="3c0a741e-f507-42f7-bca3-9784a0b638fb" name="Changes" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/Lab5.iml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Figura.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Klient.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Ksiazka.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Ksiegarnia.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Kwadrat.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Okrag.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Podrecznik.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Powiesc.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Prostokat.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Punkt.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Samochod.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/SamochodOsobowy.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Trojkat.java" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<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="Class" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="MarkdownSettingsMigration">
|
||||||
|
<option name="stateVersion" value="1" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="2HZcOD9Nt2RKM2TXQAhG5LcqWtz" />
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||||
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true"
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<option name="MAIN_CLASS_NAME" value="Main" />
|
||||||
|
<module name="Lab5" />
|
||||||
|
<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="3c0a741e-f507-42f7-bca3-9784a0b638fb" name="Changes" comment="" />
|
||||||
|
<created>1668496014923</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1668496014923</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -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>
|
|
@ -0,0 +1,25 @@
|
||||||
|
class Figura {
|
||||||
|
|
||||||
|
//pola metody i kontruktory
|
||||||
|
Punkt punkt;
|
||||||
|
String kolor = "bialy";
|
||||||
|
|
||||||
|
|
||||||
|
Figura(){
|
||||||
|
punkt = new Punkt(0,0);
|
||||||
|
}
|
||||||
|
Figura(String kolor){
|
||||||
|
this.kolor=kolor;
|
||||||
|
}
|
||||||
|
Figura(Punkt punkt){
|
||||||
|
this.punkt=punkt;
|
||||||
|
}
|
||||||
|
String getKolor(){
|
||||||
|
return kolor;
|
||||||
|
}
|
||||||
|
String opis(){
|
||||||
|
return "Klasa Figura. Kolor obiektu: "+kolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
public class Klient {
|
||||||
|
String imie, nazwisko;
|
||||||
|
|
||||||
|
public Klient(String imie, String nazwisko) {
|
||||||
|
this.imie = imie;
|
||||||
|
this.nazwisko = nazwisko;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImieNazwisko() {
|
||||||
|
return imie + " " + nazwisko;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
public class Ksiazka {
|
||||||
|
String isbn;
|
||||||
|
String tytul;
|
||||||
|
String autor;
|
||||||
|
int rokWydania;
|
||||||
|
|
||||||
|
public Ksiazka(String isbn, String tytul, String autor, int rokWydania) {
|
||||||
|
this.isbn = isbn;
|
||||||
|
this.tytul = tytul;
|
||||||
|
this.autor = autor;
|
||||||
|
this.rokWydania = rokWydania;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
System.out.println(tytul + ", " + autor + ", rok " + rokWydania);
|
||||||
|
System.out.println("ISBN: " + isbn);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
public class Ksiegarnia {
|
||||||
|
Ksiazka[] ksiazki = new Ksiazka[20];
|
||||||
|
int ksiazkiIndex = 0;
|
||||||
|
Klient[] klienci = new Klient[20];
|
||||||
|
int klienciIndex = 0;
|
||||||
|
|
||||||
|
public void addKlient(Klient k) {
|
||||||
|
klienci[klienciIndex++] = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addKlient(String imie, String nazwisko) {
|
||||||
|
Klient k = new Klient(imie, nazwisko);
|
||||||
|
klienci[klienciIndex++] = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addKsiazka(Ksiazka k) {
|
||||||
|
ksiazki[ksiazkiIndex++] = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getKsiazki() {
|
||||||
|
for(int i = 0; i < ksiazkiIndex; i++) {
|
||||||
|
ksiazki[i].opis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getKlienci() {
|
||||||
|
for(int i = 0; i < klienciIndex; i++) {
|
||||||
|
System.out.println(klienci[i].getImieNazwisko());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
public class Kwadrat extends Prostokat {
|
||||||
|
public Kwadrat(double bok) {
|
||||||
|
super(bok, bok);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getBok() {
|
||||||
|
return wys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBok(double bok) {
|
||||||
|
wys = bok;
|
||||||
|
szer = bok;
|
||||||
|
}
|
||||||
|
|
||||||
|
String opis(){
|
||||||
|
return "Klasa Kwadrat. Kolor obiektu: " + kolor + ", bok " + szer;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
/*System.out.println("=== Zadanie 1 (punkty) ===");
|
||||||
|
Punkt p1 = new Punkt();
|
||||||
|
Punkt p2 = new Punkt(2, 3);
|
||||||
|
Punkt p3 = new Punkt(Math.PI, Math.E);
|
||||||
|
|
||||||
|
System.out.println(p1.getX() + ", " + p1.getY());
|
||||||
|
p1.setX(10);
|
||||||
|
p1.setY(20);
|
||||||
|
System.out.println(p1.getX() + ", " + p1.getY());
|
||||||
|
|
||||||
|
p2.opis();
|
||||||
|
p2.zeruj();
|
||||||
|
p2.opis();
|
||||||
|
|
||||||
|
p3.opis();
|
||||||
|
p3.przesun(2, -1);
|
||||||
|
p3.opis();
|
||||||
|
|
||||||
|
Figura f1 = new Figura();
|
||||||
|
Figura f2 = new Figura(p3);
|
||||||
|
Figura f3 = new Figura("czarny");
|
||||||
|
|
||||||
|
System.out.println(f1.opis());
|
||||||
|
System.out.println(f3.getKolor());
|
||||||
|
|
||||||
|
Prostokat pr1 = new Prostokat(4, 6.5);
|
||||||
|
System.out.println(pr1.getPowierzchnia());
|
||||||
|
|
||||||
|
Trojkat t1 = new Trojkat(3.5, 6);
|
||||||
|
System.out.println(t1.podst + ", " + t1.wys);
|
||||||
|
|
||||||
|
System.out.println(pr1.opis());
|
||||||
|
pr1.przesun(3, 5);
|
||||||
|
System.out.println(pr1.opis());
|
||||||
|
|
||||||
|
Kwadrat k1 = new Kwadrat(4);
|
||||||
|
|
||||||
|
System.out.println(k1.opis());
|
||||||
|
System.out.println(pr1.opis());
|
||||||
|
System.out.println(t1.opis());
|
||||||
|
System.out.println(f1.opis());
|
||||||
|
|
||||||
|
Okrag o1 = new Okrag(p3, 5);
|
||||||
|
|
||||||
|
System.out.println(o1.opis());
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("=== Zadanie 2 (samochody) ===");
|
||||||
|
SamochodOsobowy s1 = new SamochodOsobowy();
|
||||||
|
Samochod s2 = new Samochod();
|
||||||
|
Samochod citroen = new Samochod("Citroen", "C2", "E477F56BA1", "srebrny", 2004, 245000);
|
||||||
|
|
||||||
|
s1.opis();
|
||||||
|
s2.opis();
|
||||||
|
citroen.opis();*/
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("=== Zadanie 3 (kompozycja) ===");
|
||||||
|
Ksiegarnia ks = new Ksiegarnia();
|
||||||
|
ks.addKlient("Stefan", "Stefanowski");
|
||||||
|
Klient k = new Klient("Zdzichu", "Zdzichowski");
|
||||||
|
ks.addKlient(k);
|
||||||
|
|
||||||
|
Ksiazka ks1 = new Ksiazka("9780786222728", "Harry Potter and the Philosopher's Stone", "J. K. Rowling", 1997);
|
||||||
|
Powiesc ks2 = new Powiesc("9780545229937", "The Hunger Games", "Suzanne Collins", 2009, "fantastyka");
|
||||||
|
Podrecznik ks3 = new Podrecznik("1234567890123", "Wczoraj i dzis", "Stefan Zdzichowski", 2012, "historia", 2023);
|
||||||
|
|
||||||
|
ks.addKsiazka(ks1);
|
||||||
|
ks.addKsiazka(ks2);
|
||||||
|
ks.addKsiazka(ks3);
|
||||||
|
|
||||||
|
ks.getKsiazki();
|
||||||
|
ks.getKlienci();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
public class Okrag extends Figura {
|
||||||
|
double promien;
|
||||||
|
|
||||||
|
public Okrag(Punkt srodek, double promien) {
|
||||||
|
this.punkt = srodek;
|
||||||
|
this.promien = promien;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Okrag() {
|
||||||
|
punkt = new Punkt();
|
||||||
|
promien = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPowierzchnia() {
|
||||||
|
return Math.PI * Math.pow(promien, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSrednica() {
|
||||||
|
return 2 * Math.PI * promien;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPromien(double p) {
|
||||||
|
if(p < 0) throw new IllegalArgumentException("Promien musi byc liczba dodatnia");
|
||||||
|
promien = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPromien() {
|
||||||
|
return promien;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean wSrodku(Punkt p) {
|
||||||
|
if(p.x > promien || p.y > promien) return false;
|
||||||
|
double tempX = Math.pow(p.x - punkt.x, 2);
|
||||||
|
double tempY = Math.pow(p.y - punkt.y, 2);
|
||||||
|
if(tempX + tempY <= Math.pow(promien, 2)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String opis(){
|
||||||
|
return "Klasa Okrag. Kolor obiektu: " + kolor + ", srodek " + punkt.getX() + ", " + punkt.getY() + ", promien " + getPromien();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
public class Podrecznik extends Ksiazka {
|
||||||
|
String przedmiot;
|
||||||
|
int rocznik;
|
||||||
|
|
||||||
|
public Podrecznik(String isbn, String tytul, String autor, int rokWydania, String przedmiot, int rocznik) {
|
||||||
|
super(isbn, tytul, autor, rokWydania);
|
||||||
|
this.przedmiot = przedmiot;
|
||||||
|
this.rocznik = rocznik;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
super.opis();
|
||||||
|
System.out.println("Przedmiot " + przedmiot + " dla rocznika " + rocznik);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
public class Powiesc extends Ksiazka {
|
||||||
|
String gatunek;
|
||||||
|
|
||||||
|
public Powiesc(String isbn, String tytul, String autor, int rokWydania, String gatunek) {
|
||||||
|
super(isbn, tytul, autor, rokWydania);
|
||||||
|
this.gatunek = gatunek;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
super.opis();
|
||||||
|
System.out.println("Gatunek" + gatunek);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
class Prostokat extends Figura {
|
||||||
|
double wys=0, szer=0;
|
||||||
|
|
||||||
|
Prostokat(double wys,double szer){
|
||||||
|
super();
|
||||||
|
this.wys = wys;
|
||||||
|
this.szer = szer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Prostokat(double wys, double szer, String kolor) {
|
||||||
|
super(kolor);
|
||||||
|
this.wys = wys;
|
||||||
|
this.szer = szer;
|
||||||
|
}
|
||||||
|
|
||||||
|
double getPowierzchnia() {
|
||||||
|
return (szer * wys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void przesun(int x, int y) {
|
||||||
|
szer += x;
|
||||||
|
wys += y;
|
||||||
|
}
|
||||||
|
|
||||||
|
String opis(){
|
||||||
|
return "Klasa Prostokat. Kolor obiektu: " + kolor + ", wysokosc " + wys + ", szerokosc " + szer;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
public class Punkt {
|
||||||
|
public double x, y;
|
||||||
|
|
||||||
|
public Punkt() {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Punkt(double x, double y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(double x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setY(double y) {
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zeruj() {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
System.out.println("Punkt (" + x + ", " + y + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void przesun(double x, double y) {
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Samochod {
|
||||||
|
String marka, model, nadwozie, kolor;
|
||||||
|
int rokProdukcji, przebieg;
|
||||||
|
|
||||||
|
public Samochod() {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
System.out.print("Marka: ");
|
||||||
|
marka = scanner.next();
|
||||||
|
System.out.print("Model: ");
|
||||||
|
model = scanner.next();
|
||||||
|
System.out.print("Nadwozie: ");
|
||||||
|
nadwozie = scanner.next();
|
||||||
|
System.out.print("Kolor: ");
|
||||||
|
kolor = scanner.next();
|
||||||
|
System.out.print("Rok produkcji: ");
|
||||||
|
rokProdukcji = scanner.nextInt();
|
||||||
|
System.out.print("Przebieg: ");
|
||||||
|
przebieg = scanner.nextInt();
|
||||||
|
if(przebieg < 0) throw new IllegalArgumentException("Przebieg nie moze byc ujemny");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Samochod(String marka, String model, String nadwozie, String kolor, int rokProdukcji, int przebieg) {
|
||||||
|
this.marka = marka;
|
||||||
|
this.model = model;
|
||||||
|
this.nadwozie = nadwozie;
|
||||||
|
this.kolor = kolor;
|
||||||
|
this.rokProdukcji = rokProdukcji;
|
||||||
|
this.przebieg = przebieg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
System.out.println("Samochod marki " + marka);
|
||||||
|
System.out.println("Model " + model);
|
||||||
|
System.out.println("Nadwozie " + nadwozie);
|
||||||
|
System.out.println("Kolor " + kolor);
|
||||||
|
System.out.println("Rok produkcji " + rokProdukcji);
|
||||||
|
System.out.println("Przebieg " + przebieg);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class SamochodOsobowy extends Samochod {
|
||||||
|
double waga, pojemnoscSilnika;
|
||||||
|
int iloscOsob;
|
||||||
|
|
||||||
|
public SamochodOsobowy() {
|
||||||
|
super();
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
System.out.print("Waga: ");
|
||||||
|
waga = scanner.nextDouble();
|
||||||
|
if(waga < 2 || waga > 4.5) throw new IllegalArgumentException("Waga musi byc w przedziale 2-4.5");
|
||||||
|
System.out.print("Pojemnosc silnika: ");
|
||||||
|
pojemnoscSilnika = scanner.nextDouble();
|
||||||
|
if(pojemnoscSilnika < 0.8 || pojemnoscSilnika > 3) throw new IllegalArgumentException("Pojemnosc silnika musi byc w przedziale 0.8-3.0");
|
||||||
|
System.out.print("Ilosc osob: ");
|
||||||
|
iloscOsob = scanner.nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void opis() {
|
||||||
|
System.out.println("Samochod osobowy marki " + marka);
|
||||||
|
System.out.println("Model " + model);
|
||||||
|
System.out.println("Nadwozie " + nadwozie);
|
||||||
|
System.out.println("Kolor " + kolor);
|
||||||
|
System.out.println("Rok produkcji " + rokProdukcji);
|
||||||
|
System.out.println("Przebieg " + przebieg);
|
||||||
|
System.out.println("Waga " + waga + " t");
|
||||||
|
System.out.println("Pojemnosc silnika " + pojemnoscSilnika + " cc");
|
||||||
|
System.out.println("Ilosc osob " + iloscOsob);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
class Trojkat extends Figura {
|
||||||
|
double wys=0, podst=0;
|
||||||
|
|
||||||
|
Trojkat(double wys, double podst) {
|
||||||
|
super();
|
||||||
|
this.wys = wys;
|
||||||
|
this.podst = podst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Trojkat(double wys, double podst, String kolor) {
|
||||||
|
super(kolor);
|
||||||
|
this.wys = wys;
|
||||||
|
this.podst = podst;
|
||||||
|
}
|
||||||
|
|
||||||
|
String opis(){
|
||||||
|
return "Klasa Trojkat. Kolor obiektu: " + kolor + ", wysokosc " + wys + ", podstawa " + podst;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue