Permalink
Browse files

Partway through refactoring prompts to a properties file, but it be d…

…inner time
  • Loading branch information...
1 parent 7bd2c9e commit a6fbf3365cd0ffb6244e5ee996191ed1bae45a3d @nathanh89 nathanh89 committed Nov 10, 2012
View
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
View
@@ -0,0 +1,17 @@
+welcome = Welcome to BudgetBoss!\nManage your money...like a boss.
+existingBudget = Is there an existing budget you want to open? (y/n)
+openBudget = Which budget do you want to open? (#)
+inValidEntryYN = Invalid entry! Try again.(y/n)")
+searchingDirectory = Searching for budgets...
+noBudgetFound = You don't have any saved budgets there!"
+noBudgetToSave = No budget to save!
+dontSearchBudgets = Not gonna open a budget? I can dig it.
+createNewBudget = Would you like to create a new budget? (y/n)
+getBudgetName = Let's make a budget!\nWhat do you want to name the budget? (This will be the filename)
+fuckThisProgram = You've got no saved budgets...and you don't want to make one...\nSo I can only assume you're flipping me off right now. Adios, amigo.
+getSaveDirectoryPath = Where do you want to save the budget then? Enter path below:
+badPathInput = That's not a valid path, yo. Enter y for the default or enter a path:
+notEvenANumberGenius = That's...not a number. Try again!
+thatsNotAChoice = That's not one you can choose from, yo. WTF? Try again!
+wTF = Something has gone wrong. ABORT THE BABIES!"
+adios = Budget saved! Adios, amigo.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,17 @@
+welcome = Welcome to BudgetBoss!\nManage your money...like a boss.
+existingBudget = Is there an existing budget you want to open? (y/n)
+openBudget = Which budget do you want to open? (#)
+inValidEntryYN = Invalid entry! Try again.(y/n)")
+searchingDirectory = Searching for budgets...
+noBudgetFound = You don't have any saved budgets there!"
+noBudgetToSave = No budget to save!
+dontSearchBudgets = Not gonna open a budget? I can dig it.
+createNewBudget = Would you like to create a new budget? (y/n)
+getBudgetName = Let's make a budget!\nWhat do you want to name the budget? (This will be the filename)
+fuckThisProgram = You've got no saved budgets...and you don't want to make one...\nSo I can only assume you're flipping me off right now. Adios, amigo.
+getSaveDirectoryPath = Where do you want to save the budget then? Enter path below:
+badPathInput = That's not a valid path, yo. Enter y for the default or enter a path:
+notEvenANumberGenius = That's...not a number. Try again!
+thatsNotAChoice = That's not one you can choose from, yo. WTF? Try again!
+wTF = Something has gone wrong. ABORT THE BABIES!"
+adios = Budget saved! Adios, amigo.
@@ -3,89 +3,25 @@
import com.VSSBudgetBoss.main.BudgetBoss;
public class ConsoleOutput {
-
- public static void welcomeToBudgetBoss(){
- System.out.println("Welcome to BudgetBoss!");
- System.out.println("Manage your money...like a boss.");
- }
-
- public static void existingBudgetPrompt(){
- System.out.println("Is there an existing budget you want to open? (y/n)");
- }
-
- public static void openBudgetPrompt(){
- System.out.println ("Which budget do you want to open? (#)");
- }
-
- public static void invalidEntryPromptYOrN(){
- System.out.println("Invalid entry! Try again.(y/n)");
- }
-
- public static void searchingDirectory(){
- System.out.println("Searching for budgets...");
- }
-
- public static void noBudgetFound(){
- System.out.println("You don't have any saved budgets there!");
- }
-
- public static void noBudgetToSave(){
- System.out.println("No budget to save!");
- }
-
- public static void dontSearchBudgets(){
- System.out.println("Not gonna open a budget? I can dig it.");
- }
-
- public static void createNewBudgetPrompt(){
- System.out.println("Would you like to create a new budget? (y/n)");
- }
-
- public static void getBudgetNamePrompt(){
- System.out.println("Let's make a budget!");
- System.out.println("What do you want to name the budget? (This will be the filename)");
- }
-
+
public static void creatingBudget(String name){
System.out.println("Creating budget " + name + "...");
}
- public static void fuckThisProgram(){
- System.out.println("You've got no saved budgets...and you don't want to make one...");
- System.out.println("So I can only assume you're flipping me off right now. Adios, amigo!");
- }
-
public static void getLoadDirectoryPath(){
System.out.println("Where is the budget saved? The default directory is:");
System.out.println(BudgetBoss.getDefaultDirectory());
System.out.println("Enter y for the default, or enter path below:");
}
- public static void getSaveDirectoryPath(String defaultDirectory){
- System.out.println("Where do you want to save the budget then? Enter path below:");
- }
-
- public static void badPathInput(String defaultDirectory){
- System.out.println("That's not a valid path, yo. Enter y for the default or enter a path:");
+ public static void giveDefaultDir(){
System.out.println("(" + defaultDirectory + " is the default)");
}
public static void pathToSalvationCheck(String defaultDirectory){
System.out.println("Save in " + defaultDirectory + "? (y/n)");
}
-
- public static void NotEvenANumberGenius() {
- System.out.println("That's...not a number. Try again!");
- }
-
- public static void ThatsNotAChoice() {
- System.out.println("That's not one you can choose from, yo. WTF? Try again!");
- }
- public static void wTF(){
- System.out.println("Something has gone wrong. ABORT THE BABIES!");
- }
-
public static void openingSelectedBudget(String name) {
System.out.println("Opening " + name);
}
@@ -13,16 +13,16 @@
public void askToOpenBudget(String defaultDirectory){
InputValidator validator = new InputValidator();
InputListener listener = new InputListener();
- ConsoleOutput.existingBudgetPrompt();
+ BudgetBoss.printPrompt("existingBudget");
String validatedInput = validator.inputIsEitherYOrN(listener.listenForInput());
if(validatedInput.equals("y"))
getUserDirectoryPath(defaultDirectory);
else if(validatedInput.equals("n")){
- ConsoleOutput.dontSearchBudgets();
+ BudgetBoss.printPrompt("dontSearchBudgets");
promptNeedsToClear = false;
}
else
- ConsoleOutput.invalidEntryPromptYOrN();
+ BudgetBoss.printPrompt("invalidEntryYN");
}
private void getUserDirectoryPath(String defaultDirectory){
@@ -35,11 +35,11 @@ private void getUserDirectoryPath(String defaultDirectory){
String userPath = listener.listenForInput();
validatedPath = validator.defaultDirectoryCheck(userPath, defaultDirectory);
}
- ConsoleOutput.searchingDirectory();
+ BudgetBoss.printPrompt("searchingDirectory");
File[] foundBudgets = finder.findBudgets(validatedPath);
if(foundBudgets.length > 0){
finder.printFoundBudgets(foundBudgets);
- ConsoleOutput.openBudgetPrompt();
+ BudgetBoss.printPrompt("openBudget");
int index = -1;
while(index < 0)
index = getBudgetNumberToOpen(foundBudgets);
@@ -50,7 +50,7 @@ private void getUserDirectoryPath(String defaultDirectory){
promptNeedsToClear = false;
}
else
- ConsoleOutput.noBudgetFound();
+ BudgetBoss.printPrompt("noBudgetFound");
}
private int getBudgetNumberToOpen(File[] foundBudgets){
@@ -69,25 +69,25 @@ private Budget loadBudget(int index, File[] foundBudgets){
try {
newBudget = new FileInputStream(foundBudgets[index].toString());
} catch (FileNotFoundException e) {
- ConsoleOutput.wTF();
+ BudgetBoss.printPrompt("wTF");
System.out.println("Error making the FileInputStream");
}
try {
toLoad = new ObjectInputStream(newBudget);
} catch (IOException e) {
- ConsoleOutput.wTF();
+ BudgetBoss.printPrompt("wTF");
System.out.println("Error making the ObjectInputStream");
}
try {
loadedBudget = toLoad.readObject();
} catch (ClassNotFoundException | IOException e) {
- ConsoleOutput.wTF();
+ BudgetBoss.printPrompt("wTF");
System.out.println("IO exception, maybe the file is bad?");
}
try {
toLoad.close();
} catch (IOException e) {
- ConsoleOutput.wTF();
+ BudgetBoss.printPrompt("wTF");
System.out.println("Couldn't close the Object/File input streams.");
}
return (Budget) loadedBudget;
@@ -6,6 +6,7 @@
import com.VSSBudgetBoss.cli.InputListener;
import com.VSSBudgetBoss.cli.InputValidator;
import com.VSSBudgetBoss.cli.ConsoleOutput;
+import com.VSSBudgetBoss.main.BudgetBoss;
public class Salvation {
@@ -17,7 +18,7 @@ public void autoSave(String fileName, Budget budget, String pathToSalvation){
if(validatedInput.equals("y"))
writeBudgetToDisk(fileName, budget, pathToSalvation);
else if(validatedInput.equals("n")){
- ConsoleOutput.getSaveDirectoryPath(pathToSalvation);
+ BudgetBoss.printPrompt("getSaveDirectoryPath");
pathToSalvation = getUserSaveDirectory(pathToSalvation);
writeBudgetToDisk(fileName, budget, pathToSalvation);
}
@@ -40,7 +41,7 @@ private void writeBudgetToDisk(String fileName, Budget budget, String pathToSalv
ObjectOutputStream saveOutput = new ObjectOutputStream(autoSave);
saveOutput.writeObject(budget);
saveOutput.close();
- System.out.println("Budget saved! Adios, amigo.");
+ BudgetBoss.printPrompt("adios");
}catch(Exception ex){
ex.printStackTrace();
}
@@ -9,23 +9,23 @@
private static boolean budgetless = true;
public void bestMakeABudgetNow(){
- ConsoleOutput.createNewBudgetPrompt();
+ BudgetBoss.printPrompt("createNewBudget");
InputValidator validator = new InputValidator();
InputListener listener = new InputListener();
String validatedInput = validator.inputIsEitherYOrN(listener.listenForInput());
if(validatedInput.equals("y"))
getBudgetName();
else if(validatedInput.equals("n")){
- ConsoleOutput.fuckThisProgram();
+ BudgetBoss.printPrompt("fuckThisProgram");
budgetless = false;
}
else
- ConsoleOutput.invalidEntryPromptYOrN();
+ BudgetBoss.cliOutput.getString("invalidEntryYN");
}
private void getBudgetName(){
InputListener listener = new InputListener();
- ConsoleOutput.getBudgetNamePrompt();
+ BudgetBoss.printPrompt("getBudgetName");
String desiredName = listener.listenForInput();
ConsoleOutput.creatingBudget(desiredName);
Budget newBudget = new Budget(desiredName);
@@ -1,15 +1,21 @@
package com.VSSBudgetBoss.main;
+import java.util.ResourceBundle;
import com.VSSBudgetBoss.budget.Budget;
-import com.VSSBudgetBoss.cli.*;
import com.VSSBudgetBoss.fileops.*;
public class BudgetBoss {
static Opener opener = new Opener();
static TheCreator god = new TheCreator();
static Budget currentBudget = null;
- static String defaultDirectory;
+ static String defaultDirectory;
+
+ public static ResourceBundle cliOutput = ResourceBundle.getBundle("cliOutput");
+
+ public static void printPrompt(String toGet){
+ System.out.println(cliOutput.getString(toGet));
+ }
public static void setDefaultDirectory(String newDefaultDirectory){
defaultDirectory = newDefaultDirectory;
@@ -28,20 +34,18 @@ public static void main(String args[]){
String currentUser = System.getProperty("user.name");
defaultDirectory = "/home/" + currentUser + "/Documents/";
- ConsoleOutput.welcomeToBudgetBoss();
+ System.out.println(cliOutput.getString("welcome"));
while(opener.promptNeedsToClear())
opener.askToOpenBudget(defaultDirectory);
while(TheCreator.isSlackingOnFinances())
god.bestMakeABudgetNow();
- //System.out.println("Confirm correct Budget loaded:" + currentBudget.getName());
-
try{
savior.autoSave(currentBudget.getName(), currentBudget, defaultDirectory);
}catch (NullPointerException e){
- ConsoleOutput.noBudgetToSave();
+ System.out.println(cliOutput.getString("noBudgetToSave"));
}
}
}

0 comments on commit a6fbf33

Please sign in to comment.