Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

week project completed #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
124 changes: 124 additions & 0 deletions .idea/uiDesigner.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.

72 changes: 72 additions & 0 deletions src/main/java/org/example/Company.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.example;

import java.util.Arrays;

public class Company {
private int id;
private String name;
private double giro;
private String[] developerNames;

public Company(int id, String name, double giro, String[] developerNames) {
this.id = id;
this.name = name;
setGiro(giro);
this.developerNames = developerNames;
}

public void addEmployee(int index, String name) {
if (index < 0 || index >= developerNames.length) {
System.out.println("Invalid index: " + index);
} else if (developerNames[index] != null) {
System.out.println("Developer at index " + index + " is already occupied.");
} else {
developerNames[index] = name;
}
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

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

public double getGiro() {
return giro;
}

public void setGiro(double giro) {
if (giro < 0) {
throw new IllegalArgumentException("Giro cannot be negative.");
}
this.giro = giro;
}

public String[] getDeveloperNames() {
return developerNames;
}

public void setDeveloperNames(String[] developerNames) {
this.developerNames = developerNames;
}

@Override
public String toString() {
return "Company{" +
"id=" + id +
", name='" + name + '\'' +
", giro=" + giro +
", developerNames=" + Arrays.toString(developerNames) +
'}';
}
}
80 changes: 80 additions & 0 deletions src/main/java/org/example/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.example;

import java.util.Arrays;

public class Employee {
private long id;
private String fullName;
private String email;
private String password;
private String[] healthPlans;

public Employee(long id, String fullName, String email, String password, String[] healthPlans) {
this.id = id;
this.fullName = fullName;
this.email = email;
this.password = password;
this.healthPlans = healthPlans;
}

public void addHealthPlan(int index, String name){
if(index < 0 || index >= healthPlans.length){
System.out.println("Invalid index");
}else if(healthPlans[index] != null){
System.out.println("Health plan is already done");
}else {
healthPlans[index] = name;
}
}

public long getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public String getEmail() {
return email;
}

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

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String[] getHealthPlans() {
return healthPlans;
}

public void setHealthplans(String[] healthPlans) {
this.healthPlans = healthPlans;
}

@Override
public String toString() {
return "Employee{" +
"id=" + id +
", fullName='" + fullName + '\'' +
", email='" + email + '\'' +
", password='" + password + '\'' +
", healthPlans=" + Arrays.toString(healthPlans) +
'}';
}
}
48 changes: 48 additions & 0 deletions src/main/java/org/example/Healthplan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.example;

import org.example.enums.Plan;

public class Healthplan {
private int id;
private String name;
private Plan plan;

public Healthplan(int id, String name, Plan plan) {
this.id = id;
this.name = name;
this.plan = plan;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

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

public Plan getPlan() {
return plan;
}

public void setPlan(Plan plan) {
this.plan = plan;
}

@Override
public String toString() {
return "Healthplan{" +
"id=" + id +
", name='" + name + '\'' +
", plan=" + plan +
'}';
}
}
32 changes: 31 additions & 1 deletion src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
package org.example;

import org.example.enums.Plan;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
Healthplan healthplan1 = new Healthplan(1, "Health Plan A", Plan.BASIC);
Healthplan healthplan2 = new Healthplan(2, "Health Plan B", Plan.PREMIUM);

System.out.println(healthplan1);
System.out.println(healthplan2);

String[] healthplansArray = new String[3];
healthplansArray[0] = healthplan1.getName();
healthplansArray[1] = healthplan2.getName();

Employee employee = new Employee(1, "John Doe", "[email protected]", "password123", healthplansArray);

employee.addHealthPlan(0, "BASIC");
employee.addHealthPlan(1, "PREMIUM");
employee.addHealthPlan(5, "Ultimate Health Plan"); // Geçersiz indeks
employee.addHealthPlan(0, "Extra Health Plan"); // Zaten dolu

System.out.println(employee);

// Company objesi oluşturma ve işlemler
String[] developers = new String[3];
Company company = new Company(1, "Tech Solutions", 500000.0, developers);

company.addEmployee(0, "John Doe");
company.addEmployee(1, "Jane Smith");
company.addEmployee(3, "Mark Johnson"); // Geçersiz indeks
company.addEmployee(0, "Michael Brown"); // Zaten dolu

System.out.println(company);
}
}
Loading