Files
GseTDDUebungKCLR/build/jacocoHtml/hhn.temp.project/AssignmentManager.java.html

73 lines
5.3 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="de"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AssignmentManager.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Template</a> &gt; <a href="index.source.html" class="el_package">hhn.temp.project</a> &gt; <span class="el_source">AssignmentManager.java</span></div><h1>AssignmentManager.java</h1><pre class="source lang-java linenums">package hhn.temp.project;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AssignmentManager {
Map&lt;Integer, Worker&gt; workerMap;
Map&lt;Integer, Task&gt; taskMap;
int workerIdCounter;
int taskIdCounter;
<span class="fc" id="L14"> public AssignmentManager() {</span>
<span class="fc" id="L15"> workerMap = new HashMap&lt;&gt;();</span>
<span class="fc" id="L16"> taskMap = new HashMap&lt;&gt;();</span>
<span class="fc" id="L17"> int workerIdCounter = 1000;</span>
<span class="fc" id="L18"> int taskIdCounter = 0;</span>
<span class="fc" id="L19"> }</span>
public int createWorker(String name) {
<span class="fc" id="L22"> Worker worker = new Worker(name, ++workerIdCounter);</span>
<span class="fc" id="L23"> workerMap.put(workerIdCounter, worker);</span>
<span class="fc" id="L24"> return workerIdCounter;</span>
}
public int addTask(int workerId, String name, String description) {
<span class="pc bpc" id="L27" title="1 of 6 branches missed."> if (!workerMap.containsKey(workerId) || name == null || description == null) {</span>
<span class="fc" id="L28"> throw new IllegalArgumentException(&quot;WorkerId must exist and name or description can't be null&quot;);</span>
}
<span class="fc" id="L30"> Task task = new Task(++taskIdCounter, workerId, name, description, this);</span>
<span class="fc" id="L31"> taskMap.put(taskIdCounter, task);</span>
<span class="fc" id="L32"> return taskIdCounter;</span>
}
public Task getTask(int taskId) {
<span class="fc bfc" id="L35" title="All 2 branches covered."> if (!taskMap.containsKey(taskId)) {</span>
<span class="fc" id="L36"> throw new IllegalArgumentException(&quot;Task Id does not exist&quot;);</span>
}
<span class="fc" id="L38"> return taskMap.get(taskId);</span>
}
public Map&lt;Integer, Task&gt; getTaskMap() {
<span class="fc" id="L41"> return taskMap;</span>
}
public void editTask(int workerId, int taskId, String name, String description) {
<span class="fc bfc" id="L44" title="All 4 branches covered."> if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {</span>
<span class="fc" id="L45"> throw new IllegalArgumentException(&quot;Task Id or Worker Id does not exist&quot;);</span>
}
<span class="fc" id="L47"> Task task = taskMap.get(taskId);</span>
<span class="fc" id="L48"> task.setName(name);</span>
<span class="fc" id="L49"> task.setDescription(description);</span>
<span class="fc" id="L50"> }</span>
public void removeTask(int taskId) {
<span class="fc bfc" id="L52" title="All 2 branches covered."> if (!taskMap.containsKey(taskId)) {</span>
<span class="fc" id="L53"> throw new IllegalArgumentException(&quot;Task Id does not exist&quot;);</span>
}
<span class="fc" id="L55"> taskMap.remove(taskId);</span>
<span class="fc" id="L56"> }</span>
public void finishTask(int workerId, int taskId) {
<span class="pc bpc" id="L58" title="1 of 4 branches missed."> if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {</span>
<span class="fc" id="L59"> throw new IllegalArgumentException(&quot;Task Id or Worker Id does not exist&quot;);</span>
}
<span class="fc" id="L61"> Task task = taskMap.get(taskId);</span>
<span class="fc" id="L62"> task.setTaskState(TaskState.FINISHED);</span>
<span class="fc" id="L63"> }</span>
public void unfinishTask(int workerId, int taskId) {
<span class="pc bpc" id="L65" title="1 of 4 branches missed."> if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {</span>
<span class="fc" id="L66"> throw new IllegalArgumentException(&quot;Task Id or Worker Id does not exist&quot;);</span>
}
<span class="fc" id="L68"> Task task = taskMap.get(taskId);</span>
<span class="fc" id="L69"> task.setTaskState(TaskState.IN_PROGRESS);</span>
<span class="fc" id="L70"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.13.202504020838</span></div></body></html>