Skip to content

Commit

Permalink
Add pop command (closes #9), update to v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineJT committed Sep 29, 2019
1 parent 4ea7d71 commit e300f3b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'com.github.antoinejt'
version '0.3.7'
version '0.4.0'

sourceCompatibility = 1.8

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/github/antoinejt/jasc/ConsoleUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class ConsoleUI {
private static final List<String> commands = Collections.unmodifiableList(new ArrayList<String>() {{
addAll(functions.keySet()); // functions are added here
addAll(operators.keySet()); // operators are added here
addAll(Arrays.asList("=", "help", "clear", "quit")); // Commands
addAll(Arrays.asList("=", "help", "clear", "pop", "quit")); // Commands
}});

// TODO Replace that by some txt templates (use of MVC
Expand Down Expand Up @@ -61,6 +61,7 @@ private static void displayHelp() {
"= : Print the content of the stack",
"help : Show the list of available commands",
"clear : Reset stack content",
"pop : Remove last number from the stack",
"quit : Allows to quit").print();
}

Expand Down Expand Up @@ -133,6 +134,9 @@ static void useConsole() throws Exception {
case "clear":
calculatorEngine.clear();
break;
case "pop":
calculatorEngine.removeLastNumber();
break;
case "quit":
System.exit(0);
default:
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/antoinejt/jasc/Constants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.antoinejt.jasc;

final class Constants {
static final String VERSION = "0.3.7";
static final String LAST_UPDATE = "September 28th 2019";
static final String VERSION = "0.4.0";
static final String LAST_UPDATE = "September 29th 2019";
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public void applyFunction(FunctionType functionType) throws CalculatorException
}
}

public void removeLastNumber(){
stack.pop();
}

public void operate(OperationType operation) throws OperandException, CalculatorException {
int stackSize = stack.getSize();

Expand Down

0 comments on commit e300f3b

Please sign in to comment.