upload
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m2s

This commit is contained in:
Jan-Philipp Luithardt
2025-12-03 17:57:30 +01:00
parent ed7bd7d1ed
commit 3ddc6bbc15
50 changed files with 282 additions and 114 deletions

View File

@@ -1,5 +1,7 @@
package hhn.temp.project;
import hhn.temp.project.expections.TaskHasNoWorkerException;
public class Task {
private String name;
@@ -7,16 +9,10 @@ public class Task {
private TaskStatus taskStatus;
private int taskID;
private static int idCounter = 0;
private String workername;
public Task(String name, String description) {
if (name == null || description == null ) {
throw new IllegalArgumentException("Name/Description is null!");
}
if(name.isEmpty()) {
throw new IllegalArgumentException("Name is empty!");
}
this.name = name;
this.description = description;
@@ -26,11 +22,11 @@ public class Task {
}
public int getTaskID() {
return taskID;
return this.taskID;
}
public String getName() {
return name;
return this.name;
}
public String getDescription() {
@@ -59,4 +55,34 @@ public class Task {
this.taskStatus = taskStatus;
}
public void setWorker(String workerName) {
if(workerName == null || workerName.isEmpty()) {
throw new IllegalArgumentException("There is nothing in this variable.");
}
if(!checkOnlyLetter(workerName)){
throw new IllegalArgumentException("Only Lettery as Worker Name!");
}
this.workername = workerName;
this.setStatus(TaskStatus.INPROCESS);
}
public String getWorker() {
if(this.workername == null) {
throw new TaskHasNoWorkerException("Please set first a Worker");
}
return this.workername;
}
private boolean checkOnlyLetter(String text) {
boolean result = true;
for(int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if(!Character.isLetter(c)) {
result = false;
break;
}
}
return result;
}
}

View File

@@ -16,16 +16,25 @@ public class TaskManager {
}
public Task createTask(String name, String description) {
if (name == null || description == null ) {
throw new IllegalArgumentException("Name/Description is null!");
}
if(name.isEmpty()) {
throw new IllegalArgumentException("Name is empty!");
}
if(!checkOnlyLetterOrDigit(name)) {
throw new TaskAlreadyExistsException("Only Letters or Digit are allowed in the name: " + name);
throw new IllegalArgumentException("Only Letters or Digit are allowed in the name: " + name);
}
boolean taskExited = this.taskMap.values().stream().anyMatch(task -> task.getName().equals(name));
if(taskExited) {
throw new TaskAlreadyExistsException("Task already exits, with the name: " + name);
}
Task task = new Task(name, description);
taskMap.put(task.getTaskID(), task);
return task;
@@ -72,16 +81,16 @@ public class TaskManager {
}
return result;
}
private boolean checkOnlyLetter(String text) {
boolean result = true;
for(int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if(!Character.isLetter(c)) {
result = false;
break;
}
}
return result;
}
// private boolean checkOnlyLetter(String text) {
// boolean result = true;
//
// for(int i = 0; i < text.length(); i++) {
// char c = text.charAt(i);
// if(!Character.isLetter(c)) {
// result = false;
// break;
// }
// }
// return result;
// }
}

View File

@@ -1,5 +1,5 @@
package hhn.temp.project;
public enum TaskStatus {
OPEN, CLOSED, IN_PROCESS
OPEN, CLOSED, INPROCESS
}

View File

@@ -6,3 +6,4 @@ public class TaskAlreadyExistsException extends RuntimeException {
super(message);
}
}

View File

@@ -0,0 +1,8 @@
package hhn.temp.project.expections;
public class TaskHasNoWorkerException extends RuntimeException {
public TaskHasNoWorkerException(String message) {
super(message);
}
}