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/.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..da842f2 --- /dev/null +++ b/Standart-Input-And-Classes/src/Main.java @@ -0,0 +1,33 @@ +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), + 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"))) { + 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 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 0000000..cc31bac Binary files /dev/null and b/out/production/lab-java-standard-input-and-classes/Employee.class differ diff --git a/out/production/lab-java-standard-input-and-classes/Intern.class b/out/production/lab-java-standard-input-and-classes/Intern.class new file mode 100644 index 0000000..17cacd9 Binary files /dev/null and b/out/production/lab-java-standard-input-and-classes/Intern.class differ 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 0000000..da3c57f Binary files /dev/null and b/out/production/lab-java-standard-input-and-classes/Main.class differ