From 3a1dbda3bfc3b06cc3edfc3536564b5085d6315e Mon Sep 17 00:00:00 2001 From: URLeeo Date: Fri, 20 Feb 2026 17:04:20 +0400 Subject: [PATCH 1/2] Completed Task 2 That About Standart Input And Classes --- Standart-Input-And-Classes/.gitignore | 30 ++++++++++++ Standart-Input-And-Classes/.idea/.gitignore | 10 ++++ Standart-Input-And-Classes/.idea/misc.xml | 6 +++ Standart-Input-And-Classes/.idea/modules.xml | 8 ++++ Standart-Input-And-Classes/.idea/vcs.xml | 6 +++ .../Standart-Input-And-Classes.iml | 11 +++++ Standart-Input-And-Classes/src/Employee.java | 46 +++++++++++++++++++ Standart-Input-And-Classes/src/Intern.java | 20 ++++++++ Standart-Input-And-Classes/src/Main.java | 26 +++++++++++ 9 files changed, 163 insertions(+) create mode 100644 Standart-Input-And-Classes/.gitignore create mode 100644 Standart-Input-And-Classes/.idea/.gitignore create mode 100644 Standart-Input-And-Classes/.idea/misc.xml create mode 100644 Standart-Input-And-Classes/.idea/modules.xml create mode 100644 Standart-Input-And-Classes/.idea/vcs.xml create mode 100644 Standart-Input-And-Classes/Standart-Input-And-Classes.iml create mode 100644 Standart-Input-And-Classes/src/Employee.java create mode 100644 Standart-Input-And-Classes/src/Intern.java create mode 100644 Standart-Input-And-Classes/src/Main.java diff --git a/Standart-Input-And-Classes/.gitignore b/Standart-Input-And-Classes/.gitignore new file mode 100644 index 0000000..13275f1 --- /dev/null +++ b/Standart-Input-And-Classes/.gitignore @@ -0,0 +1,30 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.kotlin + +### 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 \ No newline at end of file diff --git a/Standart-Input-And-Classes/.idea/.gitignore b/Standart-Input-And-Classes/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/Standart-Input-And-Classes/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Standart-Input-And-Classes/.idea/misc.xml b/Standart-Input-And-Classes/.idea/misc.xml new file mode 100644 index 0000000..9bb6421 --- /dev/null +++ b/Standart-Input-And-Classes/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Standart-Input-And-Classes/.idea/modules.xml b/Standart-Input-And-Classes/.idea/modules.xml new file mode 100644 index 0000000..7330b3c --- /dev/null +++ b/Standart-Input-And-Classes/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Standart-Input-And-Classes/.idea/vcs.xml b/Standart-Input-And-Classes/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Standart-Input-And-Classes/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Standart-Input-And-Classes/Standart-Input-And-Classes.iml b/Standart-Input-And-Classes/Standart-Input-And-Classes.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Standart-Input-And-Classes/Standart-Input-And-Classes.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Standart-Input-And-Classes/src/Employee.java b/Standart-Input-And-Classes/src/Employee.java new file mode 100644 index 0000000..8d9210a --- /dev/null +++ b/Standart-Input-And-Classes/src/Employee.java @@ -0,0 +1,46 @@ +class Employee { + private String name; + private String email; + private int age; + private double salary; + + public Employee(String name, String email, int age, double salary) { + setName(name); + setEmail(email); + setAge(age); + setSalary(salary); + } + + public String getName() { return name; } + public String getEmail() { return email; } + public int getAge() { return age; } + public double getSalary() { return salary; } + + public void setName(String name) { + if (name == null || name.isBlank()) { + throw new IllegalArgumentException("Name can't be empty"); + } + this.name = name; + } + + public void setEmail(String email) { + if (email == null || email.isBlank() || !email.contains("@")) { + throw new IllegalArgumentException("Email must contain '@'"); + } + this.email = email; + } + + public void setAge(int age) { + if (age <= 0 || age >= 200) { + throw new IllegalArgumentException("Age must be between 1 and 199"); + } + this.age = age; + } + + public void setSalary(double salary) { + if (salary <= 0) { + throw new IllegalArgumentException("Salary must be greater than 0"); + } + this.salary = salary; + } +} diff --git a/Standart-Input-And-Classes/src/Intern.java b/Standart-Input-And-Classes/src/Intern.java new file mode 100644 index 0000000..efd9036 --- /dev/null +++ b/Standart-Input-And-Classes/src/Intern.java @@ -0,0 +1,20 @@ +public class Intern extends Employee{ + + public static final double MAX_SALARY = 2000.0; + + public Intern(String name, String email, int age, double salary) { + super(name, email, age, salary); + } + + @Override + public void setSalary(double salary) { + super.setSalary(validateSalary(salary)); + } + + private static double validateSalary(double salary) { + if (salary > MAX_SALARY) { + throw new IllegalArgumentException("Intern salary cannot exceed " + MAX_SALARY); + } + return salary; + } +} diff --git a/Standart-Input-And-Classes/src/Main.java b/Standart-Input-And-Classes/src/Main.java new file mode 100644 index 0000000..c6857b6 --- /dev/null +++ b/Standart-Input-And-Classes/src/Main.java @@ -0,0 +1,26 @@ +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + +public class Main { + public static void main(String[] args) { + Employee[] employees = new Employee[] { + new Employee("Alice Johnson", "alice@company.com", 28, 52000), + new Employee("Bob Smith", "bob@company.com", 35, 68000), + new Employee("Cathy Brown", "cathy@company.com", 24, 47000), + new Employee("David Lee", "david@company.com", 41, 82000), + }; + + try (BufferedWriter writer = new BufferedWriter(new FileWriter("employees.txt"))) { + for (Employee e : employees) { + writer.write("Name: " + e.getName() + " " + + "Email: " + e.getEmail() + " " + + "Age: " + e.getAge() + " " + + "Salary: " + e.getSalary()); + writer.newLine(); + } + } catch (IOException ex) { + System.err.println("Failed to write employees.txt: " + ex.getMessage()); + } + } + } \ No newline at end of file From edd81462d4803c3e2e71810a8588b6bb87065e3b Mon Sep 17 00:00:00 2001 From: URLeeo Date: Fri, 20 Feb 2026 17:09:38 +0400 Subject: [PATCH 2/2] Modified Write --- .idea/.gitignore | 10 ++++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ Standart-Input-And-Classes/src/Main.java | 7 +++++++ employees.txt | 10 ++++++++++ lab-java-standard-input-and-classes.iml | 11 +++++++++++ .../Employee.class | Bin 0 -> 1704 bytes .../Intern.class | Bin 0 -> 1466 bytes .../Main.class | Bin 0 -> 2395 bytes 10 files changed, 58 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 employees.txt create mode 100644 lab-java-standard-input-and-classes.iml create mode 100644 out/production/lab-java-standard-input-and-classes/Employee.class create mode 100644 out/production/lab-java-standard-input-and-classes/Intern.class create mode 100644 out/production/lab-java-standard-input-and-classes/Main.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f5bd2df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0423cee --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Standart-Input-And-Classes/src/Main.java b/Standart-Input-And-Classes/src/Main.java index c6857b6..da842f2 100644 --- a/Standart-Input-And-Classes/src/Main.java +++ b/Standart-Input-And-Classes/src/Main.java @@ -9,6 +9,13 @@ public static void main(String[] args) { new Employee("Bob Smith", "bob@company.com", 35, 68000), new Employee("Cathy Brown", "cathy@company.com", 24, 47000), new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + new Employee("David Lee", "david@company.com", 41, 82000), + }; try (BufferedWriter writer = new BufferedWriter(new FileWriter("employees.txt"))) { diff --git a/employees.txt b/employees.txt new file mode 100644 index 0000000..6cb6c20 --- /dev/null +++ b/employees.txt @@ -0,0 +1,10 @@ +Name: Alice Johnson Email: alice@company.com Age: 28 Salary: 52000.0 +Name: Bob Smith Email: bob@company.com Age: 35 Salary: 68000.0 +Name: Cathy Brown Email: cathy@company.com Age: 24 Salary: 47000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 +Name: David Lee Email: david@company.com Age: 41 Salary: 82000.0 diff --git a/lab-java-standard-input-and-classes.iml b/lab-java-standard-input-and-classes.iml new file mode 100644 index 0000000..e84f666 --- /dev/null +++ b/lab-java-standard-input-and-classes.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/lab-java-standard-input-and-classes/Employee.class b/out/production/lab-java-standard-input-and-classes/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..cc31bacbaf9b8155651bb1e3038b0f80ffa65e73 GIT binary patch literal 1704 zcmZvc-ESL36vfZlPHb;CiQ^=0noXJ|N$anqX`pbdwrY&M10*nC`jF6+L5@w=|)`X3sI=JH1-5=h2jTDStsK%&$-X|~U#G!Q?P z{-J1bHkYfsKBek+T(7YcWKLR`(rJt>wS?PL$4y&EV}=|q?lqVn%aw!hISUzFHIU>^ zRWwECOl=>7K zZF>paHZY@va_Yj%`c6$cvUTF0nb^RastZ;EcUai2s^A?9@8Uh`TyJ~6aJ^Fl_OQD9 z$D&h}pLeBKmpl0<3A}G0qm^}9-BaHQ)12&XHi5eamMCzrLu^g@UrOmYTaNIaIa}M? z39!pcfzpGhMn?)?b{zj$cn)jN5A(zBUevzKF0nWJ?PnBus^WU`u-mH1&ZnZ*&;qSAQBwp1w4hpQA8YQVpey zUHl6s8<71L6Tf5Qv-IXGZ2eg%o?~9MAgWuCreMGv$7g~g2GZN1^c6f!B|A$z;eUL0lHq%YE1*RhJ_A@Qjv-`tFZ1p4m2FEDsP8?%kO==ggVT{r%_rPXGlJ3 zY`eC%qL5CN-snR;?`XF=U-lZdTV3jm6!Ym#16_zkVVLNKNrs~9Sq)dA_fR|bj`pmw zc68%NA(YCe^CI1Aq7QL}*uLfco7{}7eq3dTKoo-tlP3)n9mlF_C)cPR)GXI4ysKDy zo?UmlFwDA^VshWtNmjJ$*1e>~8fz!Hkj-Z2vIYh)B5p?&hE8!NE&>=caS7wJz`k-- zP9u~mwlY^tBn8{WOrfT2N6IHnT$Nyy!3|xrBzE1z6sBpddSWe@YS~Vk$Y6%_%=z?8 z6a{p{#2n_y&VNHt?ur7+VwWI zb099(>N`C8O15il9Mrb0#tXgeFp?886SI48e4 zCb(1qE`q`+Zefw3 zG@^-f6Y*WO=QdA5F%ix*aZLsl@CViDEZlNNJA8P@VD4!foceSoFdyeB;Mp%{0`s+= O0?wWROxT()k^c+4l-O4Q literal 0 HcmV?d00001 diff --git a/out/production/lab-java-standard-input-and-classes/Main.class b/out/production/lab-java-standard-input-and-classes/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..da3c57fd01f0fb3023752127b5f73852331d4ead GIT binary patch literal 2395 zcmaJ?U2qds6#j0TWH({4A#Fm7Py!Zgq-_uowFQNwtrU}jq!ugw-6WS}>1H?XZrVot z7yo~r9Upz+86V0FjQGm<;&WepaKk;wwC9aI=&=lfNViE<@m$ZtCt+485a?MFlE@I#a0{R$T}c zA%?9d4ZR@Zr>(N-Sf&b%VH=mwiGo$BaBORneuiMm%ExmR-7Tw#GW6xGe0zxBzVSk+7-HCx=5DzjPubQg<@6xsRFFWs z!!N%#9d^^{(|koQ#xwF(d&s;fU)#<9@O$P8_A$h~%ylc7s$IM&Y*9RK>#ndBJj@We zw>PUBqJgVO5L2Sbn=|3AxgqSw0m;M|L$nJMiNz2`Fd;3H4E;?Dir6@DO71IoRKp=0 zW>8APo#z$7Fff|vBvG0^rs1eGRmpUw!gWJ}PiS}&lcX|%Crji`D$mJ{V;YWwR1eZd zjvL&rdwbIn;^2galSnaaukdA&woIb-Jjp^U$K|H$Fidv2P-j*oZ6_#iJ*`n~5-ITbJ)m(C3zQ(ld~e z&Qs(~g+qtLMlWixo zIx5~_*dtqNGS1>&zsLpkh@2W7K`RySF~n!7n?y10T5<2T@y)Dcqmxx%03U>K1s^K- zNXq;%!^r(g)y)-aStJ`;H`-~I7hFrW+}Ewu&@^mhc#4}vLpUQD%UZ5gyL>oX1Zs0! zs8>Z7^HzQv-~OrAvTGiZ=7y1@o+M$kInxw&+Themj)Kn^_I2E;TdE4aU>N>?Q(1A| zy|4#@eo^x2p(df96pbZ%OVZ3}_CInR?3%Y-rcrJa2%Sc)xxR#DdJDopg%EP?8T0-_ zVCit^dnil2H))6jBU{2d2e9=z`f^J?4~j$v!Ve7~=0ScB8jS1+4-R0b2L(K6I1&#h z2C&zIluk(Pgu-1s!(Cj%-F$-`=VfkUWa%dMFGWVLg9sVV9+)4$b=22;)F1Unec$5X zc+`JrGB7q2SjRy*9FfE0a+tb-r-5~($JQ}>#m}zZ{fSm{R}r0W%v&aX<3ql6%#Z(Y z75&-out4~WH}JCbdhHr|vB6?&7cy*^?PdGuYkQj|*&+JU^+HOLLYPJcw-Ln#Vz`6t z_!EQphyK$HJ6I6gnMS|pFk&o*U35~EC9#`M*u@TGn57W+!WL2rbBx0Cf=g?0b0FJ2fyu&@8T1}LiGMAKF60B`VWPxP)z^; literal 0 HcmV?d00001