package seedu.ezdo.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.ezdo.model.todo.ReadOnlyTask;

public class TaskCard extends UiPart<Region> {

    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private AnchorPane priorityColor;
    @FXML
    private Label name;
    @FXML
    private Label id;
    @FXML
    private Label priority;
    @FXML
    private Label startDate;
    @FXML
    private Label dueDate;
    @FXML
    private FlowPane tags;

    public TaskCard(ReadOnlyTask task, int displayedIndex) {
        super(FXML);
        name.setText(task.getName().fullName);
        id.setText(displayedIndex + ". ");
        setPriority(task);
        startDate.setText(task.getStartDate().value);
        dueDate.setText(task.getDueDate().value);
        initTags(task);
    }

    private void setPriority(ReadOnlyTask task) {
        String priorityInString = task.getPriority().value;
        priority.setText(priorityInString);

        switch (priorityInString) {

        case "1":
            priorityColor.setStyle("-fx-background-color: green");
            break;
        case "2":
            priorityColor.setStyle("-fx-background-color: orange");
            break;
        case "3":
            priorityColor.setStyle("-fx-background-color: red");
            break;
        default:

        }

    }

    private void initTags(ReadOnlyTask task) {
        task.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
    }
}

@@ -17,16 +17,43 @@
 do.ui;%0A%0A
+import java.util.HashMap;%0A%0A
 import j
@@ -356,54 +356,781 @@
 ate 
-static final String FXML = %22TaskListCard.fxml%22
+String priorityInString;%0A%0A    private static final String DEFAULT_PRIORITY_NUMBER = new String();%0A    private static final String DEFAULT_PRIORITY_COLOR = %22transparent%22;%0A%0A    private static final String LOW_PRIORITY_NUMBER = %221%22;%0A    private static final String LOW_PRIORITY_COLOR = %22green%22;%0A%0A    private static final String MEDIUM_PRIORITY_NUMBER = %222%22;%0A    private static final String MEDIUM_PRIORITY_COLOR = %22orange%22;%0A%0A    private static final String HIGH_PRIORITY_COLOR = %22red%22;%0A    private static final String HIGH_PRIORITY_NUMBER = %223%22;%0A%0A    private static final String FXML = %22TaskListCard.fxml%22;%0A    private static final String CSS_BACKGROUND_COLOR = %22-fx-background-color: %22;%0A%0A    public static final HashMap%3CString, String%3E priorityColorHashMap = new HashMap%3C%3E(3)
 ;%0A%0A 
@@ -1513,16 +1513,51 @@
 (FXML);%0A
+        setPriorityColorHashMap();%0A
         
@@ -1801,30 +1801,29 @@
     %7D%0A%0A    p
-rivate
+ublic
  void setPri
@@ -1831,44 +1831,75 @@
 rity
-(ReadOnlyTask task) %7B%0A        
+InString(String priorityInString) %7B%0A        this.priorityIn
 String
+ =
  pri
@@ -1915,90 +1915,153 @@
 ring
- = task.getPriority().value;%0A        priority.setText(priorityInString
+;%0A    %7D%0A%0A    private void setPriorityColorHashMap() %7B%0A        priorityColorHashMap.put(DEFAULT_PRIORITY_NUMBER, DEFAULT_PRIORITY_COLOR
 );%0A
-%0A
         
 swit
@@ -2060,227 +2060,424 @@
     
-switch (priorityInString) %7B%0A%0A        case %221%22:%0A            priorityColor.setStyle(%22-fx-background-color: green%22
+priorityColorHashMap.put(LOW_PRIORITY_NUMBER, LOW_PRIORITY_COLOR);%0A        priorityColorHashMap.put(MEDIUM_PRIORITY_NUMBER, MEDIUM_PRIORITY_COLOR);%0A        priorityColorHashMap.put(HIGH_PRIORITY_NUMBER, HIGH_PRIORITY_COLOR
 );%0A    
+%7D%0A%0A
     
-    break;%0A        case %222%22:%0A            priorityColor.setStyle(%22-fx-background-color: orange%22);%0A
+private void setPriority(ReadOnlyTask task) %7B%0A        setPriorityInString(task.getPriority().value);%0A        priority.setText(priorityInString); // Invisible in UI (for testing%0A   
     
@@ -2484,31 +2484,24 @@
         
-break;%0A
         
 case %223%22
@@ -2496,22 +2496,42 @@
     
-case %223%22:%0A
+         
     
+        // purposes)%0A
     
@@ -2561,85 +2561,75 @@
 yle(
-%22-fx-background-color: red%22);%0A            break;%0A        default:%0A%0A        %7D%0A
+CSS_BACKGROUND_COLOR + priorityColorHashMap.get(priorityInString));
 %0A   

Access priorityColor using priorityColorHashMap instead of switch statements; Restrict access to priorityInString variable; Extract magic numbers 1, 2, 3; Extract magic strings "-fx-background-color:", "green", "orange", "red"