Lab 4 full

This commit is contained in:
Aelita4 2022-11-14 21:41:09 +01:00
parent 6a4af426ea
commit 4d75b2732c
Signed by: Aelita4
GPG Key ID: E44490C2025906C1
21 changed files with 401 additions and 67 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

124
.idea/uiDesigner.xml Normal file
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.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>

View File

@ -2,23 +2,26 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="563d5a49-589a-44ca-b92d-59680eab1914" name="Changes" comment=""> <list default="true" id="563d5a49-589a-44ca-b92d-59680eab1914" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/Building.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/wsiiz/geometry/GeoCalculator.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Genre.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/wsiiz/students/StudentArray.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/GetStudentData.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Person.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/PersonData.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Rectangle1.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Student.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Circle.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Cone.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Cube.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Cuboid.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/GeoCalculator.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Rectangle.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Sphere.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/geometry/Square.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Building.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Building.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Genre.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Genre.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/GetStudentData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/GetStudentData.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Person.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Person.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/PersonData.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/PersonData.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Rectangle1.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Rectangle1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Student.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/Student.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Circle.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Circle.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Cone.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Cone.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Cube.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Cube.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Cuboid.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Cuboid.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/GeoCalculator.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Rectangle.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Rectangle.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Sphere.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Sphere.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/geometry/Square.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/wsiiz/geometry/Square.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -49,12 +52,14 @@
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true" "RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"last_opened_file_path": "/mnt/SSD/lab4"
} }
}]]></component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" /> <option name="MAIN_CLASS_NAME" value="wsiiz.Main" />
<module name="Lab4" /> <module name="Lab4" />
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
@ -74,9 +79,13 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1667890605459</updated> <updated>1667890605459</updated>
<workItem from="1668454790509" duration="3115000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES"> <option name="TAB_STATES">
<map> <map>

View File

@ -1,28 +0,0 @@
package geometry;
import java.util.Scanner;
public class GeoCalculator {
public static void start() {
int choice;
Scanner scanner = new Scanner(System.in);
System.out.println("1. Circle");
System.out.println("2. Cone");
System.out.println("3. Cube");
System.out.println("4. Cuboid");
System.out.println("5. Rectangle");
System.out.println("6. Sphere");
System.out.println("7. Square");
while(true) {
choice = scanner.nextInt();
if(choice >= 1 && choice <= 7) break;
}
switch(choice) {
case 1:
}
}
}

View File

@ -1,3 +1,5 @@
package wsiiz;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Period; import java.time.Period;
@ -13,7 +15,7 @@ public class Building {
} }
public void displayBuildingData() { public void displayBuildingData() {
System.out.println("Building " + name); System.out.println("wsiz.Building " + name);
System.out.println("with " + floors + " floors"); System.out.println("with " + floors + " floors");
System.out.println("Built " + Math.abs(Period.between(LocalDate.now(), date).getYears()) + " years ago"); System.out.println("Built " + Math.abs(Period.between(LocalDate.now(), date).getYears()) + " years ago");
} }

View File

@ -1,3 +1,5 @@
package wsiiz;
public class Genre { public class Genre {
String typeName; String typeName;
String genreName; String genreName;
@ -23,7 +25,7 @@ public class Genre {
public String getAll() { public String getAll() {
return "Type name: " + typeName + return "Type name: " + typeName +
"\nGenre name: " + genreName + "\nwsiz.Genre name: " + genreName +
"\nChromosomes number: " + chromosomes + "\nChromosomes number: " + chromosomes +
"\nBase X chromosomes number: " + baseXchromosomes + "\nBase X chromosomes number: " + baseXchromosomes +
"\nDescription: " + desc; "\nDescription: " + desc;

View File

@ -1,3 +1,5 @@
package wsiiz;
import java.util.Scanner; import java.util.Scanner;
public class GetStudentData { public class GetStudentData {

View File

@ -1,11 +1,15 @@
import geometry.*; package wsiiz;
import wsiiz.geometry.*;
import wsiiz.students.StudentArray;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("=== Zadanie L.1 (prostokąt) ==="); System.out.println("=== Zadanie L.1 (prostokąt) ===");
Rectangle1 rect1 = new Rectangle1(3, 4); wsiiz.Rectangle1 rect1 = new wsiiz.Rectangle1(3, 4);
System.out.println("Rectangle W:" + rect1.width + " H:" + rect1.height); System.out.println("Rectangle W:" + rect1.width + " H:" + rect1.height);
System.out.println("Area: " + rect1.getArea()); System.out.println("Area: " + rect1.getArea());
System.out.println("Circumference: " + rect1.getCircumference()); System.out.println("Circumference: " + rect1.getCircumference());
@ -13,17 +17,17 @@ public class Main {
System.out.println("=== Zadanie L.2 (budynek) ==="); System.out.println("=== Zadanie L.2 (budynek) ===");
Building b1 = new Building(LocalDate.of(1991, 4, 1), "wsiz", 3); wsiiz.Building b1 = new wsiiz.Building(LocalDate.of(1991, 4, 1), "wsiiz", 3);
b1.displayBuildingData(); b1.displayBuildingData();
System.out.println("=== Zadanie L.3 (gatunki) ==="); System.out.println("=== Zadanie L.3 (gatunki) ===");
Genre cat = new Genre("cat", "felis domestic", 20, 10, "Garfield"); wsiiz.Genre cat = new wsiiz.Genre("cat", "felis domestic", 20, 10, "Garfield");
System.out.println(cat.getAll()); System.out.println(cat.getAll());
System.out.println(cat.getFullName()); System.out.println(cat.getFullName());
System.out.println(cat.getChromosomes()); System.out.println(cat.getChromosomes());
Genre notDog = cat.clone(); wsiiz.Genre notDog = cat.clone();
System.out.println(notDog.getAll()); System.out.println(notDog.getAll());
System.out.println(notDog.getFullName()); System.out.println(notDog.getFullName());
System.out.println(notDog.getChromosomes()); System.out.println(notDog.getChromosomes());
@ -36,14 +40,14 @@ public class Main {
System.out.println("=== Zadanie K.1 (osoba) ==="); System.out.println("=== Zadanie K.1 (osoba) ===");
PersonData.getPersonData(); wsiiz.PersonData.getPersonData();
System.out.println("=== Zadanie K.2 (student) ==="); System.out.println("=== Zadanie K.2 (student) ===");
Student s1 = new Student("Zdzichu", "Zdzichowski", 19, 12345, "IT", 2021); wsiiz.Student s1 = new wsiiz.Student("Zdzichu", "Zdzichowski", 19, 12345, "IT", 2021);
Student s2 = new Student("Eustachy", 21, 54321, "Cosmetics", 2019); wsiiz.Student s2 = new wsiiz.Student("Eustachy", 21, 54321, "Cosmetics", 2019);
Student s3 = new Student(11223, "Management", 2018); wsiiz.Student s3 = new wsiiz.Student(11223, "Management", 2018);
Student s4 = new Student("Andrzej", "Kula", 22, 32213, "Networking"); wsiiz.Student s4 = new wsiiz.Student("Andrzej", "Kula", 22, 32213, "Networking");
s1.getStudentData(); s1.getStudentData();
s2.getStudentData(); s2.getStudentData();
@ -52,7 +56,7 @@ public class Main {
System.out.println("=== Zadanie K.3 (wprowadź studenta) ==="); System.out.println("=== Zadanie K.3 (wprowadź studenta) ===");
GetStudentData.getStudentData(); wsiiz.GetStudentData.getStudentData();
System.out.println("=== Zadanie K.4 (figury) ==="); System.out.println("=== Zadanie K.4 (figury) ===");
@ -92,5 +96,25 @@ public class Main {
System.out.println(square.getCircumference()); System.out.println(square.getCircumference());
System.out.println("=== Zadanie K.4* (kalkulator geometryczny) ===");
GeoCalculator.start();
System.out.println("=== Zadanie K.5 (studenty w tablicy) ===");
StudentArray sa = new StudentArray();
sa.createStudent();
sa.createStudent();
sa.createStudent();
sa.editStudent();
sa.deleteStudent();
sa.getStudent();
System.out.println("Press Enter to get all students...");
try {
System.in.read();
} catch (IOException e) {
throw new RuntimeException(e);
}
sa.getAllStudents();
sa.getStudentsBetween();
} }
} }

View File

@ -1,3 +1,5 @@
package wsiiz;
public class Person { public class Person {
String name, surname; String name, surname;
int age; int age;

View File

@ -1,3 +1,5 @@
package wsiiz;
public class PersonData { public class PersonData {
public static void getPersonData() { public static void getPersonData() {
Person p1 = new Person("Zdzichu", "Zdzichowski", 19); Person p1 = new Person("Zdzichu", "Zdzichowski", 19);

View File

@ -1,3 +1,5 @@
package wsiiz;
public class Rectangle1 { public class Rectangle1 {
int width, height; int width, height;

View File

@ -1,3 +1,5 @@
package wsiiz;
public class Student extends Person { public class Student extends Person {
int indexNumber; int indexNumber;
String specialty; String specialty;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Circle { public class Circle {
int radius; int radius;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Cone { public class Cone {
double height, radius, slant; double height, radius, slant;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Cube { public class Cube {
int edge; int edge;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Cuboid { public class Cuboid {
int a, b, c; int a, b, c;

View File

@ -0,0 +1,92 @@
package wsiiz.geometry;
import java.util.Scanner;
public class GeoCalculator {
public static void start() {
int choice;
Scanner scanner = new Scanner(System.in);
System.out.println("1. Circle");
System.out.println("2. Cone");
System.out.println("3. Cube");
System.out.println("4. Cuboid");
System.out.println("5. Rectangle");
System.out.println("6. Sphere");
System.out.println("7. Square");
while(true) {
choice = scanner.nextInt();
if(choice >= 1 && choice <= 7) break;
}
switch(choice) {
case 1: // Circle
int circleRadius;
System.out.print("Input radius: ");
circleRadius = scanner.nextInt();
Circle circle = new Circle(circleRadius);
System.out.println("Area: " + circle.getArea());
System.out.println("Circumference: " + circle.getCircumference());
break;
case 2: // Cone
int coneHeight, coneRadius;
System.out.print("Input height: ");
coneHeight = scanner.nextInt();
System.out.print("Input radius: ");
coneRadius = scanner.nextInt();
Cone cone = new Cone(coneHeight, coneRadius);
System.out.println("Area: " + cone.getArea());
System.out.println("Volume: " + cone.getVolume());
break;
case 3: // Cube
int cubeEdge;
System.out.print("Input edge: ");
cubeEdge = scanner.nextInt();
Cube cube = new Cube(cubeEdge);
System.out.println("Area: " + cube.getArea());
System.out.println("Circumference: " + cube.getCircumference());
break;
case 4: // Cuboid
int cuboidEdgeA, cuboidEdgeB, cuboidEdgeC;
System.out.print("Input edge A: ");
cuboidEdgeA = scanner.nextInt();
System.out.print("Input edge B: ");
cuboidEdgeB = scanner.nextInt();
System.out.print("Input edge C: ");
cuboidEdgeC = scanner.nextInt();
Cuboid cuboid = new Cuboid(cuboidEdgeA, cuboidEdgeB, cuboidEdgeC);
System.out.println("Area: " + cuboid.getArea());
System.out.println("Volume: " + cuboid.getVolume());
break;
case 5: // Rectangle
int rectangleEdgeA, rectangleEdgeB;
System.out.print("Input edge A: ");
rectangleEdgeA = scanner.nextInt();
System.out.print("Input edge B: ");
rectangleEdgeB = scanner.nextInt();
Rectangle rectangle = new Rectangle(rectangleEdgeA, rectangleEdgeB);
System.out.println("Area: " + rectangle.getArea());
System.out.println("Circumference: " + rectangle.getCircumference());
break;
case 6: // Sphere
int sphereRadius;
System.out.print("Input radius: ");
sphereRadius = scanner.nextInt();
Sphere sphere = new Sphere(sphereRadius);
System.out.println("Area: " + sphere.getArea());
System.out.println("Volume: " + sphere.getVolume());
break;
case 7: // Square
int squareEdge;
System.out.print("Input edge: ");
squareEdge = scanner.nextInt();
Square square = new Square(squareEdge);
System.out.println("Area: " + square.getArea());
System.out.println("Circumference: " + square.getCircumference());
break;
default:
System.out.println("Unknown figure");
}
}
}

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Rectangle { public class Rectangle {
int width, height; int width, height;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Sphere { public class Sphere {
int radius; int radius;

View File

@ -1,4 +1,4 @@
package geometry; package wsiiz.geometry;
public class Square { public class Square {
int edge; int edge;

View File

@ -0,0 +1,99 @@
package wsiiz.students;
import wsiiz.Student;
import java.util.Scanner;
public class StudentArray {
Student[] students = new Student[100];
boolean[] initialized = new boolean[100];
private Scanner scanner = new Scanner(System.in);
public StudentArray() {
for (int i = 0; i < 100; i++) {
students[i] = new Student("", "", 0, 0, "", 0);
initialized[i] = false;
}
}
public void createStudent() {
System.out.print("Adding new student\nInput index number (0-99): ");
int index = scanner.nextInt();
if(index < 0 || index > 99) throw new IllegalArgumentException("Value must be between 0-99");
if(!initialized[index]) {
initialized[index] = true;
modifyStudent(index);
}
else System.out.println("Student already exists at index " + index + ", can't create");
}
public void editStudent() {
System.out.print("Editing student\nInput index number (0-99): ");
int index = scanner.nextInt();
if(index < 0 || index > 99) throw new IllegalArgumentException("Value must be between 0-99");
if(initialized[index]) modifyStudent(index);
else System.out.println("Student doesn't exist at index " + index + ", can't modify");
}
private void modifyStudent(int index) {
String name, surname, specialty;
int age, indexNumber, collegeYear;
System.out.print("Input new name: ");
name = scanner.next();
System.out.print("Input new surname: ");
surname = scanner.next();
System.out.print("Input new age: ");
age = scanner.nextInt();
System.out.print("Input new index number: ");
indexNumber = scanner.nextInt();
System.out.print("Input new specialty: ");
specialty = scanner.next();
System.out.print("Input new college year: ");
collegeYear = scanner.nextInt();
students[index] = new Student(name, surname, age, indexNumber, specialty, collegeYear);
}
public void deleteStudent() {
System.out.print("Deleting student\nInput index number (0-99): ");
int index = scanner.nextInt();
if(index < 0 || index > 99) throw new IllegalArgumentException("Value must be between 0-99");
if(initialized[index]) {
students[index] = new Student("", "", 0, 0, "", 0);
initialized[index] = false;
} else System.out.println("Student doesn't exist");
}
public void getStudent() {
System.out.print("Getting student\nInput index number (0-99): ");
int index = scanner.nextInt();
if(index < 0 || index > 99) throw new IllegalArgumentException("Value must be between 0-99");
if(initialized[index]) obtainStudent(index);
else System.out.println("Student doesn't exist");
}
public void getAllStudents() {
for(int i = 0; i < 100; i++) obtainStudent(i);
}
public void getStudentsBetween() {
System.out.print("Gettings students between\nInput first index number (0-99): ");
int indexOne = scanner.nextInt();
if(indexOne < 0 || indexOne > 99) throw new IllegalArgumentException("Value must be between 0-99");
System.out.print("Input second index number (" + (indexOne + 1) + "-99): ");
int indexTwo = scanner.nextInt();
if(indexTwo < indexOne || indexTwo > 99) throw new IllegalArgumentException("Value must be between " + (indexOne + 1) + "-99");
for(int i = indexOne; i <= indexTwo; i++) obtainStudent(i);
}
private void obtainStudent(int index) {
System.out.print("Info for student " + index + ": ");
students[index].getStudentData();
}
}