second commit
This commit is contained in:
parent
238c7355b7
commit
f4407d4bfe
29
Laboratorium_1_Java/.gitignore
vendored
Normal file
29
Laboratorium_1_Java/.gitignore
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
3
Laboratorium_1_Java/.idea/.gitignore
vendored
Normal file
3
Laboratorium_1_Java/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
8
Laboratorium_1_Java/.idea/compiler.xml
Normal file
8
Laboratorium_1_Java/.idea/compiler.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
6
Laboratorium_1_Java/.idea/misc.xml
Normal file
6
Laboratorium_1_Java/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="corretto-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Laboratorium_1_Java/.idea/modules.xml
Normal file
8
Laboratorium_1_Java/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Laboratorium_1_Java.iml" filepath="$PROJECT_DIR$/Laboratorium_1_Java.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
Laboratorium_1_Java/.idea/uiDesigner.xml
Normal file
124
Laboratorium_1_Java/.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
20
Laboratorium_1_Java/Laboratorium_1_Java.iml
Normal file
20
Laboratorium_1_Java/Laboratorium_1_Java.iml
Normal file
@ -0,0 +1,20 @@
|
||||
<?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" />
|
||||
<orderEntry type="module-library" scope="PROVIDED">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
59
Laboratorium_1_Java/src/Main.java
Normal file
59
Laboratorium_1_Java/src/Main.java
Normal file
@ -0,0 +1,59 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
zadanie_1_1();
|
||||
|
||||
Student s1 = new Student("Marian", "Kiepski", 22, "Informatyka", 2.5);
|
||||
Student s2 = new Student("Jan", "Kowalski", 19, "Mechanika i budowa maszyn",4.5);
|
||||
Student s3 = new Student("Tomasz", "Lewandowski", 23, "Elektrotechnika",4.76);
|
||||
|
||||
System.out.println(s1);
|
||||
System.out.println(s2);
|
||||
System.out.println(s3);
|
||||
|
||||
}
|
||||
|
||||
public static void zadanie_1_1()
|
||||
{
|
||||
List<String> przedmioty = Arrays.asList(
|
||||
"Zaawansowane programowanie w Javie", "Procesy wytwarzania oprogramowania", "Komponentowe podejście do wytwarzania aplikacji",
|
||||
"Seminarium dyplomowe", "Projekt zespołowy", "Architektura i programowanie w .NET", "Integracja systemów", "programowanie aplikacji w chmurze obliczeniowej",
|
||||
"Interakcja człowiek komputer"
|
||||
);
|
||||
|
||||
System.out.println("Lista przedmiotów z tego i poprzedniego semestru:");
|
||||
for (int i = 0; i < przedmioty.size(); i++)
|
||||
{
|
||||
System.out.println(przedmioty.get(i));
|
||||
}
|
||||
|
||||
boolean isExist = przedmioty.stream().anyMatch(element -> element.toLowerCase().contains("zaaw"));
|
||||
System.out.println("Lista przedmiotów posiada elementy zawierające 'zaaw': " + isExist);
|
||||
|
||||
Map<String, Integer> oceny = new HashMap<>();
|
||||
Random random = new Random();
|
||||
for (String przedmiot : przedmioty) {
|
||||
int ocena = random.nextInt(4) + 2;
|
||||
oceny.put(przedmiot, ocena);
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : oceny.entrySet()) {
|
||||
System.out.printf("Przedmiot: %s, Ocena: %d%n", entry.getKey(), entry.getValue());
|
||||
}
|
||||
/*Map<Integer, Long> ocenyZliczone = oceny.stream()
|
||||
/.collect(Collectors.groupingBy(ocena -> ocena, Collectors.counting()));
|
||||
|
||||
|
||||
ocenyZliczone.forEach((ocena, ilosc) -> {
|
||||
System.out.println("Ocena: " + ocena + ", Ilość: " + ilosc);
|
||||
});*/
|
||||
}
|
||||
|
||||
|
||||
private static int przypiszOcene() {
|
||||
return (int) (Math.random()*5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
14
Laboratorium_1_Java/src/Student.java
Normal file
14
Laboratorium_1_Java/src/Student.java
Normal file
@ -0,0 +1,14 @@
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Student {
|
||||
private String imie;
|
||||
private String nazwisko;
|
||||
private int wiek;
|
||||
private String kierunek;
|
||||
private double srednia;
|
||||
}
|
57
Laboratorium_1_Java/src/ZgadywanieLiczby.java
Normal file
57
Laboratorium_1_Java/src/ZgadywanieLiczby.java
Normal file
@ -0,0 +1,57 @@
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ZgadywanieLiczby {
|
||||
private int tajnaLiczba;
|
||||
private int proby;
|
||||
|
||||
public ZgadywanieLiczby() {
|
||||
Random random = new Random();
|
||||
tajnaLiczba = random.nextInt(100) + 1; // Losuje liczbę od 1 do 100
|
||||
proby = 0;
|
||||
}
|
||||
|
||||
public int pobierzWejscieUzytkownika() {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int liczba = 0;
|
||||
boolean poprawnaLiczba = false;
|
||||
|
||||
while (!poprawnaLiczba) {
|
||||
System.out.print("Zgadnij liczbę (1-100): ");
|
||||
if (scanner.hasNextInt()) {
|
||||
liczba = scanner.nextInt();
|
||||
if (liczba >= 1 && liczba <= 100) {
|
||||
poprawnaLiczba = true;
|
||||
} else {
|
||||
System.out.println("Proszę podać liczbę w zakresie od 1 do 100.");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Proszę podać poprawną liczbę.");
|
||||
scanner.next();
|
||||
}
|
||||
}
|
||||
return liczba;
|
||||
}
|
||||
|
||||
public void graj() {
|
||||
System.out.println("Witaj w grze w zgadywanie liczby!");
|
||||
while (true) {
|
||||
int zgadywanaLiczba = pobierzWejscieUzytkownika();
|
||||
proby++;
|
||||
|
||||
if (zgadywanaLiczba < tajnaLiczba) {
|
||||
System.out.println("Za mało! Spróbuj jeszcze raz.");
|
||||
} else if (zgadywanaLiczba > tajnaLiczba) {
|
||||
System.out.println("Za dużo! Spróbuj jeszcze raz.");
|
||||
} else {
|
||||
System.out.printf("Gratulacje! Zgadłeś liczbę %d w %d próbach.%n", tajnaLiczba, proby);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ZgadywanieLiczby gra = new ZgadywanieLiczby();
|
||||
gra.graj();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user