Advertisement
Guest User

Untitled

a guest
May 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. package Tax_Package;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5. import javax.swing.JOptionPane;
  6.  
  7. public class Tax_Calculator {
  8.  
  9. public void begin() {
  10. // create the Game ArrayList to store the data while the program is running
  11. ArrayList<Customer> Customerus = new ArrayList<Customer>();
  12.  
  13. // display the menu and process PC Game & Board Game data
  14. boolean finished = false;
  15. while(!finished) {
  16. // a loop to allow the program to continue until the user chooses to exit program
  17. int selection = showMenu();
  18. switch(selection) {
  19.  
  20. case 1: Customerus.add(addBusiness_Customer()); // add a PC Game
  21. break;
  22. case 2: Customerus.add(addBoardGame()); // add a Board Game
  23. break;
  24. case 3: JOptionPane.showMessageDialog(null, "Displaying the game information...", "Game List",
  25. JOptionPane.PLAIN_MESSAGE); // display the Game data
  26. for(int i = 0; i < Customerus.size(); i++) {
  27. JOptionPane.showMessageDialog(null, Customerus.get(i), "Game Details", JOptionPane.PLAIN_MESSAGE);
  28. }
  29. JOptionPane.showMessageDialog(null, "There are " + Customerus.size() + " record(s) in the list", "Totalrecords", JOptionPane.PLAIN_MESSAGE);
  30. break;
  31. case 4: finished = true; // the boolean variable 'finished' is used to control the loop
  32. JOptionPane.showMessageDialog(null, "*** Program Ended ***\n" + "*** Thank you for using this program");
  33. break;
  34. default:
  35. JOptionPane.showMessageDialog(null, "\n*** Invalid Selection ***\n", "ERROR",
  36. JOptionPane.ERROR_MESSAGE);
  37.  
  38. } //end switch
  39. } //end while loop
  40. } //end begin()
  41.  
  42. // showMenu() – User’s program selection menu
  43. public int showMenu() {
  44. int selection = 0;
  45. String stringSelection = JOptionPane.showInputDialog(
  46. "******MENU******\n\n"+
  47. "1. Add a new PC Game\n"+
  48. "2. Add a new Board Game\n"+
  49. "3. Display all games\n"+
  50. "4. Exit program\n"+
  51. "Type in the number of your selection and click OK: ");
  52. selection = Integer.parseInt(stringSelection.trim());
  53. return selection;
  54. } //end menu
  55.  
  56. // addBusiness_Customer()– Method to collect Business_Customer data
  57. public Business_Customer addTax() {
  58. String userInput = JOptionPane.showInputDialog(null, "\nWhat is your name?: ").trim();
  59. int taxFn = 0;
  60. int finYear = 0;
  61. do {
  62. String taxFnq = JOptionPane.showInputDialog(null, "\nWhat is your tax file number?: ").trim();
  63. double doubletax = Double.parseDouble(taxFnq);
  64. taxFn = (int) doubletax;
  65. if (taxFn<= 0) {
  66. JOptionPane.showMessageDialog(null, "Error -Please enter a valid Tax file number1", "ERROR",
  67. JOptionPane.ERROR_MESSAGE);
  68. }
  69. } while (taxFn <=0);
  70. do {
  71. String finYearq = JOptionPane.showInputDialog(null, "\nWhat is the financial year: ").trim();
  72. double doubleyear = Double.parseDouble(finYearq);
  73. taxFn = (int) doubleyear;
  74. if (finYear<= 0) {
  75. JOptionPane.showMessageDialog(null, "Error -Please enter a valid financial year", "ERROR",
  76. JOptionPane.ERROR_MESSAGE);
  77. }
  78. } while (finYear <=0);
  79. //String Cust = JOptionPane.showInputDialog(null, "\nWhat is the game key?");
  80. //String gRating = JOptionPane.showInputDialog(null, "\nMaturity rating of the game?");
  81.  
  82. // String gName = JOptionPane.showInputDialog(null, "\nName of store where available?");
  83. //String gLocation = JOptionPane.showInputDialog(null, "\nWhere is the store located?");
  84.  
  85. Tax ai = new Tax(gName, gLocation); //create a new Tax object
  86. Business_Customer p = new Business_Customer(n, c, (int) taxFn, ga, gGameKey, gRating); //create new Business_Customer object
  87. JOptionPane.showMessageDialog(null, "Thank you, PC Game added to the list", "PC Game added", JOptionPane.PLAIN_MESSAGE);
  88. return p;
  89. } //end addBusiness_Customer
  90.  
  91. //addBoardGame() - Method to collect BoardGame data
  92. public BoardGame addBoardGame() {
  93. String n = JOptionPane.showInputDialog(null, "\nWhat is the name of the game? ").trim();
  94. String c = JOptionPane.showInputDialog(null, "\nWhat is the category of the game? ");
  95. int taxFn = 0;
  96. do {
  97. String p = JOptionPane.showInputDialog(null, "\nWhat is the taxFn of the game? ").trim();
  98. double doubleSize = Double.parseDouble(p);
  99. taxFn = (int) doubleSize;
  100. if (taxFn<= 0) {
  101. JOptionPane.showMessageDialog(null, "Error -taxFn must be greater than zero", "ERROR",
  102. JOptionPane.ERROR_MESSAGE);
  103. }
  104. } while (taxFn <=0);
  105.  
  106. String gHasPlayers = JOptionPane.showInputDialog(null, "\nDoes it have players?");
  107. String gBrand = JOptionPane.showInputDialog(null, "\nWhat is the brand?");
  108.  
  109. String gName = JOptionPane.showInputDialog(null, "\nName of store where available?");
  110. String gLocation = JOptionPane.showInputDialog(null, "\nWhere is the store located?");
  111.  
  112.  
  113. Tax ai = new GameShop(gName, gLocation); //create a new GameShop object
  114. BoardGame bg = new BoardGame(n, c, (int) taxFn, ga, gBrand, gHasPlayers); //create new Business_Customer object
  115. JOptionPane.showMessageDialog(null, "Thank you, Board Games added to the list", "Board Game added", JOptionPane.PLAIN_MESSAGE);
  116. return bg;
  117. }
  118. } //end addBoardGame()
  119.  
  120. //end UserInterface class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement