Compare commits

..

5 Commits

Author SHA1 Message Date
Oleksii Aleshchenko 860a447ff9 change argument number 2023-02-23 15:00:01 +02:00
Oleksii Aleshchenko 53a9d20438 Update Main.java 2023-02-23 14:30:35 +02:00
Oleksii Aleshchenko 9112df275b add test code from discussion after lecture 2023-02-16 16:30:11 +02:00
Oleksii Aleshchenko 81947f9b29 add EncapsulationInheritancePolymorphism 2023-02-16 16:10:38 +02:00
Oleksii Aleshchenko f4fbabe6e5 Initial commit 2023-02-09 15:57:52 +02:00
16 changed files with 227 additions and 223 deletions
+2
View File
@@ -0,0 +1,2 @@
# Project exclude paths
/out/
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+1 -2
View File
@@ -2,8 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/lab1.iml" filepath="$PROJECT_DIR$/lab1.iml" />
<module fileurl="file://$PROJECT_DIR$/laba3/laba3.iml" filepath="$PROJECT_DIR$/laba3/laba3.iml" />
<module fileurl="file://$PROJECT_DIR$/OOP_IO-2x_2023.iml" filepath="$PROJECT_DIR$/OOP_IO-2x_2023.iml" />
</modules>
</component>
</project>
+124
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
-11
View File
@@ -1,11 +0,0 @@
<?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>
-93
View File
@@ -1,93 +0,0 @@
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String[] args) {
System.out.println("Введіть текст:");
Scanner scan = new Scanner(System.in);
String inputText = scan.nextLine();
StringBuilder text = new StringBuilder(inputText);
StringBuilder suz = new StringBuilder();
while (true){
if(text.isEmpty()){
break;
}
int index1 = text.indexOf(".");
int index2 = text.indexOf("!");
int index3 = text.indexOf("?");
int index4 = text.indexOf("...");
int[] array1= {index1, index2, index3, index4};
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < array1.length; i++) {
if (array1[i] >= 0) {
list.add(array1[i]);
}
}
int min = Collections.min(list);
String rechennya1 = text.substring(0, min);
System.out.println(rechennya1);
if (rechennya1.contains(" ")){
StringBuilder rechennya = new StringBuilder(rechennya1);
String firstword1;
String secondword1 = text.substring(rechennya.lastIndexOf(" ")+1, rechennya.length());
String secondword2;
secondword2 = secondword1.substring(0, 1).toUpperCase()+secondword1.substring(1, secondword1.length());
StringBuilder secondword = new StringBuilder(secondword2);
if(rechennya.charAt(rechennya.indexOf(" ")-1)==','){
firstword1 = text.substring(0, rechennya.indexOf(" ")-1);
secondword.append(",");
}
else {
firstword1 = text.substring(0, rechennya.indexOf(" "));
}
String firstword2 = firstword1.substring(0, 1).toLowerCase()+firstword1.substring(1, firstword1.length());
StringBuilder firstword = new StringBuilder(firstword2);
firstword.insert(0, " ");
rechennya.delete(0, rechennya.indexOf(" "));
rechennya.insert(0, secondword);
rechennya.delete(rechennya.lastIndexOf(" "), rechennya.length());
rechennya.append(firstword);
if ((index1==index4)&&(index1==min)){
rechennya.append(text.substring(min, min+3));
rechennya.append(" ");
text.delete(0, min+4);
}
else {
rechennya.append(text.substring(min, min+1));
rechennya.append(" ");
text.delete(0, min+2);
}
suz.append(rechennya);
}
else {
StringBuilder rechennya = new StringBuilder(rechennya1);
if ((index1==index4)&&(index1==min)){
rechennya.append(text.substring(min, min+3));
rechennya.append(" ");
text.delete(0, min+4);
}
else {
rechennya.append(text.substring(min, min+1));
rechennya.append(" ");
text.delete(0, min+2);
}
suz.append(rechennya);
}
}
System.out.println(suz);
}
}
Binary file not shown.
+7 -52
View File
@@ -1,60 +1,15 @@
import java.util.Scanner;
import java.util.InputMismatchException;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Введіть значення n:");
double n = 0;
try {
n = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
System.out.println("Введіть значення m:");
double m = 0;
try {
m = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
System.out.println(args[0]);
System.out.println("Hello world!");
// System.out.println(1);
}
System.out.println("Введіть значення a:");
double a = 0;
try {
a = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
System.out.println("Введіть значення b:");
double b = 0;
try {
b = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
if (a > n) {
System.out.println("Значення n має бути більшим або рівним a");
System.exit(0);
}
if (b > m) {
System.out.println("Значення m має бути більшим або рівним b");
System.exit(0);
}
double s1 = 0;
double s2 = 0;
void myFunction() {
for (double i = a; i <= n; i++) {
for (double j = b; j <= m; j++){
// оскільки C дорівнює 0, то можна скоротити i
s1=s1+(1/j);
}
s2=s2+s1;
}
System.out.println("Результат:" + s2);
int myFunction2() {
return 1;
}
}
@@ -0,0 +1,20 @@
package encapsulationInheritancePolymorphism;
public class Encapsulation {
/*private*/ int field;
private int field2;
// int a = 1;
public void myMethodForTheField () {
System.out.println(field);
}
public void myMethodForTheField2 () {
System.out.println(field);
}
public void myMethodForTheFieldAndTheField2 () {
System.out.println(field);
}
}
@@ -0,0 +1,10 @@
package encapsulationInheritancePolymorphism;
public class EncapsulationInheritancePolymorphism {
public static void main(String[] args) {
int a = 1;
// var b = 2;
// System.out.println(b);
}
}
@@ -0,0 +1,14 @@
package encapsulationInheritancePolymorphism;
public class Main {
public static void main(String[] args) {
Student student = new Student();
//...
student.setFaculty("FPM", "MO-22");
}
}
@@ -0,0 +1,18 @@
package encapsulationInheritancePolymorphism;
public class Student {
private String name;
private String surname;
private String group;
private String faculty;
public String getName() {
return name;
}
public void setFaculty(String faculty, String group) {
this.faculty = faculty;
this.group = group;
}
}
-62
View File
@@ -1,62 +0,0 @@
package lab2;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Введіть значення n:");
double n = 0;
try {
n = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
System.out.println("Введіть значення m:");
double m = 0;
try {
m = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
System.out.println("Введіть значення a:");
double a = 0;
try {
a = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
System.out.println("Введіть значення b:");
double b = 0;
try {
b = scan.nextDouble();
} catch (InputMismatchException e) {
System.out.println("Число введене не вірно");
System.exit(0);
}
if (a > n) {
System.out.println("Значення n має бути більшим або рівним a");
System.exit(0);
}
if (b > m) {
System.out.println("Значення m має бути більшим або рівним b");
System.exit(0);
}
double s1 = 0;
double s2 = 0;
for (double i = a; i <= n; i++) {
for (double j = b; j <= m; j++){
// оскільки C дорівнює 0, то можна скоротити i
s1=s1+(1/j);
}
s2=s2+s1;
}
System.out.println("Результат:" + s2);
}
}
+13
View File
@@ -0,0 +1,13 @@
package test;
public class A {
/*private*/ int f/* = 3*/;
public int getF() {
return f;
}
public void setF(int f) {
this.f = f;
}
}
+15
View File
@@ -0,0 +1,15 @@
package test;
public class Main {
public static void main(String[] args) {
A a = new A();
System.out.println(a.getF());
a.setF(1);
System.out.println(a.getF());
System.out.println(a.f);
int[] array = {1, 2, 1};
System.out.println(array.length);
}
}