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.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

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

7 changes: 7 additions & 0 deletions .idea/encodings.xml

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

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

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

9 changes: 9 additions & 0 deletions .idea/lab-java-standard-input-and-classes.iml

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

17 changes: 17 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.

17 changes: 17 additions & 0 deletions lab2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ironhack</groupId>
<artifactId>lab2</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
89 changes: 89 additions & 0 deletions lab2/src/main/java/com/ironhack/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.ironhack;

//package com.ironhack.envsetup;
import java.io.File;
import java.util.Scanner;

public class Employee {
private String name ;
private String email ;
private int age;
private double salary;
public double salaryLimit;

public Employee() {
}//bu hisse constructordu (yeqin)

public Employee(String name, String email, int age,double salary) {

this.name= name;
this.email = email;
this.age = age;
this.salary = salary;

}

//burda objecti yaratmaliyam (employee list ucun)

File myObj = new File("employees.txt");
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
System.out.println("Please enter your name:");
String name = scanner.nextLine();
System.out.println("Name is: " + name);

System.out.println("Now enter your age: ");
int age = scanner.nextInt();
System.out.println("Age is: " + age);

System.out.println("Enter your salary: " );
double salary = scanner.nextDouble();
System.out.println("Salary is: " + salary);

if (salary <= 20000) {
System.out.println("Welcome to the company!");
} else {
System.err.println(" Your salary cannot be over limit. Salary limit: 20000 ");
}
}
}
public double getsalaryLimit(){
return 20000;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public double getSalary() {
return salary;
}

public void setSalary(double salary) {
this.salary = salary;
}
}




30 changes: 30 additions & 0 deletions lab2/src/main/java/com/ironhack/Intern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.ironhack;

public class Intern extends Employee {

private double salaryLimit;
public Intern(String name, int age, String email, double salary, int salaryLimit) throws Exception {
super(name,email,age,salary);
this.salaryLimit(salaryLimit);
if (salary > salaryLimit){
throw new Exception("Intern's salary can not be higher than the 20000");
}
this.setSalary(salary);

}
public double getsalaryLimit() {
return salaryLimit();
}


public double salaryLimit() {
return 20000;
}

public void salaryLimit(int i) {
}
public String getInfo(){
return getName() + " " + getEmail() + " " + getAge() + " " + getSalary() + " " + getsalaryLimit();
}
}

17 changes: 17 additions & 0 deletions lab2/src/main/java/com/ironhack/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ironhack;

import java.io.FileWriter;
public class Main {
public static void main(String[] args) throws Exception {

try (FileWriter writer = new FileWriter("demo.txt", true)) {
for (int i = 0; i < 10; i++) {
Intern intern1 = new Intern("Intern " + i, i + 20, "email + " + i, i + 800, 20000);
writer.write(intern1.getInfo());
writer.write(System.lineSeparator());

}
}
}
}