Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

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

0 notes on commit a6fbf33

Please sign in to comment.
Something went wrong with that request. Please try again.