Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
There are long methods and arrow shaped code in the program

This reduces the readability and makes it harder for developers to maintain in the future

Refactoring code to reduce the length of methods and avoid arrow shaped code.

This will help to improve overall readability and make it easier to maintain the code in future
  • Loading branch information
rgonslayer committed Sep 19, 2022
1 parent e482d30 commit 9dc08af
Show file tree
Hide file tree
Showing 19 changed files with 333 additions and 192 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ test {
}

application {
mainClassName = "seedu.duke.Duke"
mainClassName = "jarvis.Jarvis"
}

shadowJar {
archiveBaseName = "duke"
archiveBaseName = "jarvis"
archiveClassifier = null
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
jarvis.Main-Class: jarvis.Jarvis
jarvis.GUI.Main-Class: jarvis.Jarvis

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jarvis;
package jarvis.GUI;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -58,4 +58,4 @@ public static DialogBox getDukeDialog(String text, Image img) {
db.flip();
return db;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package jarvis;
package jarvis.GUI;

import java.io.IOException;

import jarvis.Jarvis;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
Expand All @@ -28,4 +29,4 @@ public void start(Stage stage) {
e.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package jarvis;
package jarvis.GUI;

import jarvis.Jarvis;
import jarvis.Parser;
import jarvis.exception.JarvisException;
import javafx.application.Platform;
import javafx.fxml.FXML;
Expand All @@ -9,6 +11,7 @@
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

/**
* Controller for MainWindow. Provides the layout for the other controls.
*/
Expand All @@ -27,6 +30,9 @@ public class MainWindow extends AnchorPane {
private Image userImage = new Image(this.getClass().getResourceAsStream("/images/user.png"));
private Image jarvisImage = new Image(this.getClass().getResourceAsStream("/images/jarvis.png"));

/**
* Initialise the scroll window in the UI with introduction message.
*/
@FXML
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
Expand Down Expand Up @@ -54,4 +60,4 @@ private void handleUserInput() throws JarvisException {
}
userInput.clear();
}
}
}
25 changes: 16 additions & 9 deletions src/main/java/jarvis/Jarvis.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package jarvis;

import jarvis.task.TaskList;
import java.io.IOException;

import jarvis.GUI.Main;
import jarvis.exception.JarvisException;
import jarvis.task.TaskList;
import javafx.application.Application;

import java.io.IOException;

/**
* Jarvis is the main class where the program is initialised.
*/
public class Jarvis {
private static Parser parser;

public class Jarvis{
static Parser parser;
public static void main(String[] args){
/**
* Main method for program
* @param args
*/
public static void main(String[] args) {

String filePath = "data/taskList.txt";

Expand All @@ -34,10 +42,9 @@ public static void main(String[] args){
}

/**
* You should have your own function to generate a response to user input.
* Replace this stub with your completed method.
* Passes the input to the parser and returns the response
*/
String getResponse(String input) throws JarvisException {
public String getResponse(String input) throws JarvisException {
return parser.readCommand(input);
}

Expand Down
Loading

0 comments on commit 9dc08af

Please sign in to comment.