<commit_before>package edu.dynamic.dynamiz.UI;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Formatter;
import java.awt.color.*;

import edu.dynamic.dynamiz.structure.*;

/**
 * @author <NAME>
 * Implement Display functions for tasks, events and todoItems
 */
public class Displayer implements DisplayerInterface {
//	private static final String WELCOME_MESSAGE= "Welcome to Dynamiz!";
//	
//	private static final int FEEDBACK_TAG = 1;
//	private static final int ERROR_FEEDBACK_TAG = 2;
//	private static final int SUCCESS_FEEDBACK_TAG = 3;
//	private static final int HELP_FEEDBACK_TAG = 4;
	
	static final String UPDATE_COMMAND = "update";

	
	public String dateFormatter(Calendar c){
		String s = String.format("%1$tm,%1$te",c);
		return s;	
	}
	public String dateFormatter(Date d){
		
		String s = String.format("%tm,%td,%ty", d);
		return s;
	}
	public String timeFormatter(Date d){
		String s = String.format("%tH:%tM", d);
		return s;
	}
	

	public String displayWelcomeMessage(){
		return WELCOME_MESSAGE;
	}
	
	
	
	public String displayTitleLine() {
		String s=String.format("%-20s%15s   %12s  %8s  %8s   ", "Task","Status","Priority","Start Time","End Time");	
		return s;
	}

	@Override
	public String displayDividingLine() {
		String s = new String("--------------------------------------------------------------------------------------------------------");
		return s;
	}

	
	@Override
	public String displayString(String str) {	
		return str;
	}

	@Override
	public String displayStringList(ArrayList<String> arr) {	
		if(arr == null) return new String("null");

		StringBuilder s = new StringBuilder();

		for(int i=0;i<arr.size();i++){
			if(!arr.get(i).isEmpty())
			s.append(arr.get(i).trim()).append("\n");
		}

		return s.toString();	
	}
	

	@Override
	public String displayTaskItem(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.toString();
	}

	@Override
	public String displayTaskFile(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.toFileString();
	}
	
	@Override
	public String displayTaskFeedback(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.getFeedbackString();
	}

	

	@Override
	public String displayTaskList(ArrayList<TaskItem> taskList) {
		if(taskList == null ) return new String("null");
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< taskList.size(); i++){
			s.append(taskList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayTaskList(TaskItem[] taskList) {
		if(taskList == null ) return new String("null");
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< taskList.length; i++){
			s.append(taskList[i].toString()).append("\n");
		}
		return s.toString();

	}

	
	@Override
	public String displayEventFeedback(EventItem event) {
		if(event == null) return new String("null event");
		else return event.getFeedbackString();
		
	}

	@Override
	public String displayEventFile(EventItem event) {
		String s = new String("null event");
		if(event == null) return s;
		else return event.toFileString();
	}
	@Override
	public String displayEventItem(EventItem event) {
		String s = new String("null event");
		if(event == null) return s;
		else return event.toString();
	}
	
	@Override
	public String displayEventList(ArrayList<EventItem> eventList) {
		String str = new String("null event");
		if(eventList == null) return str;
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< eventList.size(); i++){
			s.append(eventList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayEventList(EventItem[] eventList) {
		String str = new String("null event");
		if(eventList == null) return str;
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< eventList.length; i++){
			s.append(eventList[i].toString()).append("\n");
		}
		return s.toString();
	}

	

	@Override
	public String displayToDoItem(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.toString();
	}

	@Override
	public String displayToDoFeedback(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.getFeedbackString();
	}

	@Override
	public String displayToDoFile(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.toFileString();
	}
	
	@Override
	public String displayToDoList(ArrayList<ToDoItem> todoList) {
		String str = new String("null todoItem");
		if(todoList == null) return str;
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< todoList.size(); i++){
			s.append(todoList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayToDoList(ToDoItem[] todoList) {
		String str = new String("null todoItem");
		if(todoList == null) return str;
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< todoList.length; i++){
			s.append(todoList[i].toString()).append("\n");
		}
		return s.toString();
	}
	


	public String displayPrompt() {
		String s = new String ("Command: ");
		return s;
	}
//	public String displayEnterCommandPrompt() {
//		String s = new String ("Please Enter Command:");
//		return s;
//	}


	public String displayPrompt(int promptTag) {
		String tag = new String();
		switch(promptTag){
		case ENTER_COMMAND_PROMPT:
			tag = ENTER_COMMAND_STR;
			break;
		case ENTER_ITEM_PROMPT:
			tag = "Please Enter Task: ";
			break;
		case ENTER_TASK_INDEX_PROMPT:
			tag = ENTER_TASK_INDEX_STR;
			break;
			
		case ENTER_TIME_PROMPT:
			tag = ENTER_TIME_PERIOD_STR;
			break;
			
		case INVALID_COMMAND_PROMPT:
			tag = ENTER_VALID_COMMAND_STR;
			break;
		default:
			tag = ENTER_VALID_COMMAND_STR;
		}	
		
		//tag+="\n";
		
		return tag;
	}

	public String displayPrompt(String promptMessage) {
		return promptMessage;
	}

	
	public String displayFeedback(Feedback commandFeedback) {
		if(commandFeedback == null ) return "null";
		String s = new String(); 
		int t = getFeedbackTag(commandFeedback);
		switch(t){
		case HELP_FEEDBACK_TAG:
			HelpFeedback hf = (HelpFeedback)commandFeedback; 
			s = hf.getHelpContent();
			break;
			
		case ERROR_FEEDBACK_TAG:
			ErrorFeedback ef = (ErrorFeedback)commandFeedback; 
			s =ef.getCommandType();<commit_msg>update string updated<commit_after>package edu.dynamic.dynamiz.UI;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Formatter;
import java.awt.color.*;

import edu.dynamic.dynamiz.structure.*;

/**
 * @author Hu Wenyan
 * Implement Display functions for tasks, events and todoItems
 */
public class Displayer implements DisplayerInterface {
//	private static final String WELCOME_MESSAGE= "Welcome to Dynamiz!";
//	
//	private static final int FEEDBACK_TAG = 1;
//	private static final int ERROR_FEEDBACK_TAG = 2;
//	private static final int SUCCESS_FEEDBACK_TAG = 3;
//	private static final int HELP_FEEDBACK_TAG = 4;
	
	static final String UPDATE_COMMAND = "update";

	
	public String dateFormatter(Calendar c){
		String s = String.format("%1$tm,%1$te",c);
		return s;	
	}
	public String dateFormatter(Date d){
		
		String s = String.format("%tm,%td,%ty", d);
		return s;
	}
	public String timeFormatter(Date d){
		String s = String.format("%tH:%tM", d);
		return s;
	}
	

	public String displayWelcomeMessage(){
		return WELCOME_MESSAGE;
	}
	
	
	
	public String displayTitleLine() {
		String s=String.format("%-20s%15s   %12s  %8s  %8s   ", "Task","Status","Priority","Start Time","End Time");	
		return s;
	}

	@Override
	public String displayDividingLine() {
		String s = new String("--------------------------------------------------------------------------------------------------------");
		return s;
	}

	
	@Override
	public String displayString(String str) {	
		return str;
	}

	@Override
	public String displayStringList(ArrayList<String> arr) {	
		if(arr == null) return new String("null");

		StringBuilder s = new StringBuilder();

		for(int i=0;i<arr.size();i++){
			if(!arr.get(i).isEmpty())
			s.append(arr.get(i).trim()).append("\n");
		}

		return s.toString();	
	}
	

	@Override
	public String displayTaskItem(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.toString();
	}

	@Override
	public String displayTaskFile(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.toFileString();
	}
	
	@Override
	public String displayTaskFeedback(TaskItem task) {
		if(task == null) return new String("null task");
		else return task.getFeedbackString();
	}

	

	@Override
	public String displayTaskList(ArrayList<TaskItem> taskList) {
		if(taskList == null ) return new String("null");
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< taskList.size(); i++){
			s.append(taskList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayTaskList(TaskItem[] taskList) {
		if(taskList == null ) return new String("null");
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< taskList.length; i++){
			s.append(taskList[i].toString()).append("\n");
		}
		return s.toString();

	}

	
	@Override
	public String displayEventFeedback(EventItem event) {
		if(event == null) return new String("null event");
		else return event.getFeedbackString();
		
	}

	@Override
	public String displayEventFile(EventItem event) {
		String s = new String("null event");
		if(event == null) return s;
		else return event.toFileString();
	}
	@Override
	public String displayEventItem(EventItem event) {
		String s = new String("null event");
		if(event == null) return s;
		else return event.toString();
	}
	
	@Override
	public String displayEventList(ArrayList<EventItem> eventList) {
		String str = new String("null event");
		if(eventList == null) return str;
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< eventList.size(); i++){
			s.append(eventList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayEventList(EventItem[] eventList) {
		String str = new String("null event");
		if(eventList == null) return str;
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< eventList.length; i++){
			s.append(eventList[i].toString()).append("\n");
		}
		return s.toString();
	}

	

	@Override
	public String displayToDoItem(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.toString();
	}

	@Override
	public String displayToDoFeedback(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.getFeedbackString();
	}

	@Override
	public String displayToDoFile(ToDoItem todoItem) {
		String str = new String("null todoItem");
		if(todoItem == null) return str;
		else return todoItem.toFileString();
	}
	
	@Override
	public String displayToDoList(ArrayList<ToDoItem> todoList) {
		String str = new String("null todoItem");
		if(todoList == null) return str;
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< todoList.size(); i++){
			s.append(todoList.get(i).toString()).append("\n");
		}
		return s.toString();
	}

	@Override
	public String displayToDoList(ToDoItem[] todoList) {
		String str = new String("null todoItem");
		if(todoList == null) return str;
		
		StringBuilder s = new StringBuilder();
		for(int i = 0; i< todoList.length; i++){
			s.append(todoList[i].toString()).append("\n");
		}
		return s.toString();
	}
	


	public String displayPrompt() {
		String s = new String ("Command: ");
		return s;
	}
//	public String displayEnterCommandPrompt() {
//		String s = new String ("Please Enter Command:");
//		return s;
//	}


	public String displayPrompt(int promptTag) {
		String tag = new String();
		switch(promptTag){
		case ENTER_COMMAND_PROMPT:
			tag = ENTER_COMMAND_STR;
			break;
		case ENTER_ITEM_PROMPT:
			tag = "Please Enter Task: ";
			break;
		case ENTER_TASK_INDEX_PROMPT:
			tag = ENTER_TASK_INDEX_STR;
			break;
			
		case ENTER_TIME_PROMPT:
			tag = ENTER_TIME_PERIOD_STR;
			break;
			
		case INVALID_COMMAND_PROMPT:
			tag = ENTER_VALID_COMMAND_STR;
			break;
		default:
			tag = ENTER_VALID_COMMAND_STR;
		}	
		
		//tag+="\n";
		
		return tag;
	}

	public String displayPrompt(String promptMessage) {
		return promptMessage;
	}

	
	public String displayFeedback(Feedback commandFeedback) {
		if(commandFeedback == null ) return "null";
		String s = new String(); 
		int t = getFeedbackTag(commandFeedback);
		switch(t){
		case HELP_FEEDBACK_TAG:
			HelpFeedback hf = (HelpFeedback)commandFeedback; 
			s = hf.getHelpContent();
			break;
			
		case ERROR_FEEDBACK_TAG:
			ErrorFeedback ef = (ErrorFeedback)commandFeedback; 
			s =ef.getCommandType()+" unsuccessful"+"\n";
{'fraction_non_alphanumeric': 0.14862143742255265, 'fraction_numerical': 0.0032527881040892194, 'mean_word_length': 3.786137879911045, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2638058', 'n_tokens_mistral': 4646, 'n_tokens_neox': 4153, 'n_words': 1091}