Skip to content

Commit

Permalink
Move files into individual packages (#22)
Browse files Browse the repository at this point in the history
* Move files into individual packages
  • Loading branch information
Anonymxtrix committed Aug 31, 2021
1 parent 0cab738 commit e22e3b0
Show file tree
Hide file tree
Showing 36 changed files with 540 additions and 397 deletions.
13 changes: 0 additions & 13 deletions src/main/java/ByeRequest.java

This file was deleted.

35 changes: 0 additions & 35 deletions src/main/java/CompleteTask.java

This file was deleted.

40 changes: 0 additions & 40 deletions src/main/java/DeleteTask.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/java/ListRequest.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/ListTasks.java

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/java/TaskCollectionRequest.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/TaskType.java

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/java/UserException.java

This file was deleted.

9 changes: 9 additions & 0 deletions src/main/java/Duke.java → src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package duke;

import duke.action.Action;
import duke.action.GoodbyeUser;
import duke.action.WelcomeUser;
import duke.exception.UserException;
import duke.request.Request;
import duke.task.TaskCollection;

import java.util.Queue;
import java.util.LinkedList;

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/Response.java → src/main/java/duke/Response.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package duke;

/**
* A Response from the application to some user input.
* A duke.Response from the application to some user input.
*/
public class Response {
public static String BASE_INDENT = " ";
Expand All @@ -18,15 +20,15 @@ public Response() {

/**
* Creates a response with the specified String message.
* @param message The Response message.
* @param message The duke.Response message.
*/
public Response(String message) {
this(new String[]{ message });
}

/**
* Creates a response with the specified String array.
* @param messages The Response message array.
* @param messages The duke.Response message array.
*/
public Response(String[] messages) {
this.message = String.join(System.lineSeparator(), messages);
Expand All @@ -43,8 +45,8 @@ public void add(String message) {
}

/**
* Converts the Response to its String representation.
* @return The String representation of the Response.
* Converts the duke.Response to its String representation.
* @return The String representation of the duke.Response.
*/
@Override
public String toString() {
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/Storage.java → src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package duke;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
* Storage class is responsible for dealing with loading tasks from file and saving tasks in the file.
* duke.Storage class is responsible for dealing with loading tasks from file and saving tasks in the file.
*/
public class Storage {
private final File file;

/**
* Creates a new Storage instance at the specified path.
* Creates a new duke.Storage instance at the specified path.
* @param pathname A pathname string
*/
public Storage(String pathname) {
Expand Down Expand Up @@ -48,21 +50,21 @@ public String read() {
scanner.close();
return contents.toString();
} catch (FileNotFoundException exception) {
throw new RuntimeException("File not found when trying to read file from Storage class.");
throw new RuntimeException("File not found when trying to read file from duke.Storage class.");
}
}

/**
* Writes the specified contents into the Storage file.
* @param contents The String contents to write to the Storage file.
* Writes the specified contents into the duke.Storage file.
* @param contents The String contents to write to the duke.Storage file.
*/
public void write(String contents) {
try {
FileWriter fileWriter = new FileWriter(this.file);
fileWriter.write(contents);
fileWriter.close();
} catch (FileNotFoundException exception) {
throw new RuntimeException("File not found when trying to write to file from Storage class.");
throw new RuntimeException("File not found when trying to write to file from duke.Storage class.");
} catch (IOException exception) {
throw new RuntimeException(
String.format("An I/O exception occurred when trying to write to file %s\n", this.file.getPath())
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/Ui.java → src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package duke;

import java.util.Scanner;

/**
* Ui represents the class that deals with interactions with the user
* duke.Ui represents the class that deals with interactions with the user
*/
public class Ui {
Scanner scanner = new Scanner(System.in);

/**
* Prints the Response to the console.
* @param response The Response to be printed.
* Prints the duke.Response to the console.
* @param response The duke.Response to be printed.
*/
public void printResponse(Response response) {
System.out.println(response.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package duke.action;

import duke.Response;

/**
* The Action interface represents an action to be performed in the Duke application.
*/
public interface Action {
/**
* Executes the specified action and returns the resulting Response.
* Executes the specified action and returns the resulting duke.Response.
*/
Response execute();
}
Loading

0 comments on commit e22e3b0

Please sign in to comment.