Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Standart-Input-And-Classes/.gitignore
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions Standart-Input-And-Classes/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Standart-Input-And-Classes/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Standart-Input-And-Classes/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Standart-Input-And-Classes/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Standart-Input-And-Classes/Standart-Input-And-Classes.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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>
46 changes: 46 additions & 0 deletions Standart-Input-And-Classes/src/Employee.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
20 changes: 20 additions & 0 deletions Standart-Input-And-Classes/src/Intern.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
33 changes: 33 additions & 0 deletions Standart-Input-And-Classes/src/Main.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
10 changes: 10 additions & 0 deletions employees.txt
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions lab-java-standard-input-and-classes.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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$/Standart-Input-And-Classes/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.