Skip to content

Commit

Permalink
fix window os bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlohyr committed Oct 14, 2023
1 parent 92685f4 commit e4f352e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
35 changes: 19 additions & 16 deletions src/main/java/seedu/duke/controllers/ModulePlannerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@

import seedu.duke.views.CommandLineView;
import seedu.duke.utils.Parser;

import java.util.Scanner;

public class ModulePlannerController {
private CommandLineView view;
private Parser parser;
public ModulePlannerController(){
private Parser parser;

public ModulePlannerController() {
this.view = new CommandLineView();
this.parser = new Parser();
}
public void start(){

public void start() {
view.displayWelcome();
Scanner in = new Scanner(System.in);
String userInput = in.nextLine();

while(!userInput.equals("Bye")){
while (!userInput.equals("Bye")) {

String[] words = userInput.split(" ");

String initialWord = words[0];

switch(initialWord){
case "hi":{
switch (initialWord) {
case "hi": {
view.displayMessage("can put the commands here");
break;
}
case "hello":{
case "hello": {
view.displayMessage("yup");
break;
}
case "pace":{
case "pace": {
//assumed that everyone graduates at y4s2
//waiting for retrieving logic
int modulesCreditsCompleted = 100;
Expand All @@ -40,7 +43,7 @@ public void start(){
computePace(words, creditsLeft);
break;
}
default:{
default: {
view.displayMessage("Hello " + userInput);
break;
}
Expand All @@ -54,18 +57,18 @@ public void start(){
* Computes the recommended pace for completing a degree based on the provided academic year
* and credits left until graduation.
*
* @param userInput An array of user input where userInput[0] is the command and userInput[1] is the academic year.
* @param userInput An array of user input where userInput[0] is the command and userInput[1] is the academic year.
* @param creditsLeft The number of credits left until graduation.
* @throws IllegalArgumentException if the provided academic year is invalid.
*/
public void computePace(String[] userInput,int creditsLeft){
public void computePace(String[] userInput, int creditsLeft) {
boolean argumentProvided = userInput.length != 1;
//wait for text file logic
if(!argumentProvided){
if (!argumentProvided) {
view.displayMessage("You currently have " + creditsLeft + " MCs till graduation");
return;
}
if(!parser.isValidAcademicYear(userInput[1])){
if (!parser.isValidAcademicYear(userInput[1])) {
return;
}

Expand All @@ -81,8 +84,8 @@ public void computePace(String[] userInput,int creditsLeft){
int semesterIntValue = Character.getNumericValue(semester.charAt(1));
//if we are at y2s1, we have 5 semesters left
int semestersLeft = (lastYearOfDegree - yearIntValue) * 2 + (lastSemesterOfYear - semesterIntValue);
int creditsPerSem = Math.round((float) creditsLeft /semestersLeft) ;
view.displayMessage("You currently have " + creditsLeft + "MCs for " + semestersLeft + " semesters");
view.displayMessage("Recommended Pace: " +creditsPerSem + "MCs per sem until graduation");
int creditsPerSem = Math.round((float) creditsLeft / semestersLeft);
view.displayMessage("You have " + creditsLeft + "MCs for " + semestersLeft + " semesters. "
+ "Recommended Pace: "+ creditsPerSem + "MCs per sem until graduation");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ void computePaceValidYear() {
String test = "hi";
// Capture the printed output
String printedOutput = outputStream.toString().trim();
String lineOne = "You currently have 60MCs for 5 semesters\n";
String lineTwo = "Recommended Pace: 12MCs per sem until graduation";
String expectedOutput = lineOne + lineTwo;
String line = "You have 60MCs for 5 semesters. Recommended Pace: 12MCs per sem until graduation";
// Assert the printed output matches the expected value
assertEquals(printedOutput, expectedOutput);
assertEquals(printedOutput, line);
}
}

0 comments on commit e4f352e

Please sign in to comment.