Guest User

Untitled

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 KB | None | 0 0
  1. package phone.phone;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Display extends PhoneAccount
  7. {
  8.  
  9. Display(String first, String add, int fone, String op, int mins, int txt) {
  10. super(first, add, fone, op, mins, txt);
  11. // TODO Auto-generated constructor stub
  12. }
  13.  
  14.  
  15. // create Account array
  16. static PhoneAccount arr1[] = new PhoneAccount[ 100 ];
  17. static int i=1;
  18.  
  19.  
  20. public static void main(String[] args)
  21. {
  22.  
  23. while (true)
  24.  
  25. {
  26. System.out.println();
  27. System.out.println(" D.I.T ");
  28. System.out.println("Eoin O' Leary-----------------");
  29. System.out.println();
  30. System.out.println(" 1. Create");
  31. System.out.println(" 2. Display");
  32. System.out.println(" 3. Edit");
  33. System.out.println(" 4. Calculate Bill");
  34. System.out.println(" 5. Make a call");
  35. System.out.println(" 6. Send Texts");
  36. System.out.println(" 7. Edit Credit");
  37. System.out.println(" 8. Option");
  38.  
  39. Scanner scanner = new Scanner(System.in);
  40. int choice = scanner.nextInt();
  41. switch (choice)
  42. {
  43. case 1:
  44. createAccounts();
  45. break;
  46.  
  47. case 2:
  48. DisplayAccount();
  49. break;
  50.  
  51. case 3:
  52. Edit();
  53. break;
  54.  
  55. case 4:
  56. CalculateBill();
  57. break;
  58. case 5:
  59. MakeCall();
  60. break;
  61.  
  62. case 6:
  63. SendText();
  64. break;
  65.  
  66. case 7:
  67. addcred();
  68. break;
  69.  
  70. case 8:
  71. Option();
  72. break;
  73. default:
  74. System.out.println("Try Again!");
  75. break;
  76. }
  77. }
  78.  
  79.  
  80.  
  81. };
  82.  
  83. public static void createAccounts()
  84. {
  85.  
  86.  
  87. {
  88. System.out.println(" \t\t Select Account: \n");
  89. System.out.println(" 1. Billpay ");
  90. System.out.println(" 2. Business ");
  91. System.out.println(" 3. Prepay ");
  92.  
  93. Scanner scanner = new Scanner(System.in);
  94. int choice = scanner.nextInt();
  95. switch (choice)
  96. {
  97. case 1:
  98. Billpay();
  99. break;
  100. case 2:
  101. Business();
  102. break;
  103. case 3:
  104. Prepay();
  105. break;
  106. default:
  107. System.out.println("Try Again!");
  108. break;
  109. }
  110.  
  111. }
  112. };
  113.  
  114. public static void Billpay()
  115. {
  116.  
  117.  
  118. Billpay var2 = new Billpay(Name,Address,Phone,Dop,MinsUsed,TxtSent,i);//create variable of type subclass
  119. arr1[i]=var2;//bind subclass to base class
  120.  
  121.  
  122.  
  123. Scanner scanner = new Scanner(System.in);
  124.  
  125. System.out.println("\t\tCreate a building\n\n");
  126. System.out.println("Account Name : ");
  127. arr1[i].Name = scanner.nextLine() ;
  128. System.out.println("Address : ");
  129. arr1[i].Address = scanner.nextLine() ;
  130. System.out.println("Phone Number : ");
  131. arr1[i].Phone = scanner.nextInt() ;
  132. System.out.println("Minutes Used : ");
  133. arr1[i].MinsUsed = scanner.nextInt();
  134. System.out.println("Text Sent : ");
  135. arr1[i].TxtSent= scanner.nextInt();
  136. System.out.println("Option Type \n1=light 2=active: ");
  137. int choice = scanner.nextInt();
  138. switch (choice)
  139. {
  140. case 1:
  141. System.out.println("You have chosen the light option");
  142. var2.option= ("light");
  143.  
  144. break;
  145. case 2:
  146. System.out.println("You have chosen the Active ");
  147. var2.option = ("active");
  148. break;
  149. default:
  150. System.out.println("Incorrect Entry!");
  151. break;
  152. }
  153. i++;//.
  154.  
  155.  
  156. }
  157.  
  158. public static void Business()
  159. {
  160.  
  161.  
  162.  
  163.  
  164. Business var2 = new Business(Name,Address,Phone,Dop,MinsUsed,TxtSent,i); //create variable of type subclass
  165. arr1[i]=var2; //bind subclass to base class
  166.  
  167.  
  168. {
  169. Scanner scanner = new Scanner(System.in);
  170.  
  171. System.out.println("\t\tCreat an Account\n\n");
  172. System.out.println("Account Name : ");
  173. arr1[i].Name = scanner.nextLine() ;
  174. System.out.println("Address : ");
  175. arr1[i].Address = scanner.nextLine() ;
  176. System.out.println("Phone Number : ");
  177. arr1[i].Phone = scanner.nextInt() ;
  178. System.out.println("Minutes : ");
  179. arr1[i].MinsUsed = scanner.nextInt();
  180. System.out.println("Minutes: ");
  181. var2.setMinsUsed(scanner.nextInt());
  182. System.out.println("Texts : ");
  183. arr1[i].TxtSent = scanner.nextInt();
  184. System.out.println("Texts : ");
  185. var2.setTxtSent(scanner.nextInt());
  186. i++;
  187. }
  188. };
  189.  
  190. public static void Prepay()
  191. {
  192.  
  193.  
  194.  
  195.  
  196. Prepay var2 = new Prepay(i);//create variable of type subclass
  197. arr1[i]=var2; //bind subclass to base class
  198.  
  199.  
  200. {
  201. Scanner scanner = new Scanner(System.in);
  202.  
  203. System.out.println("\t\tCreate Prepay account\n\n");
  204. System.out.println("Name: ");
  205. arr1[i].Name = scanner.nextLine() ;
  206. System.out.println("Address : ");
  207. arr1[i].Address = scanner.nextLine() ;
  208. System.out.println("Phone Number : ");
  209. arr1[i].Phone = scanner.nextInt() ;
  210. System.out.println("MinsUsed : ");
  211. arr1[i].MinsUsed = scanner.nextInt();
  212. System.out.println("Credit :");
  213. var2.addcred(scanner.nextInt());
  214.  
  215. i++;
  216. }
  217. }
  218.  
  219.  
  220.  
  221. public static void DisplayAccount()
  222. {
  223.  
  224.  
  225.  
  226. Scanner scanner = new Scanner(System.in);
  227. System.out.println("Account no : ");
  228. int x = scanner.nextInt();
  229.  
  230. arr1[x].toString();
  231.  
  232.  
  233.  
  234. }
  235.  
  236.  
  237.  
  238. public static void Edit()
  239. {
  240.  
  241. Scanner scanner = new Scanner(System.in);
  242. System.out.println("Account : ");
  243. int x = scanner.nextInt();
  244. arr1[x].toString();
  245. System.out.println("\t\tEdit Account\n\n");
  246. System.out.println("Account Name : ");
  247. scanner.nextLine() ;
  248. arr1[x].Name = scanner.nextLine() ;
  249. System.out.println("Address : ");
  250. arr1[x].Address = scanner.nextLine() ;
  251. System.out.println("Phone Number : ");
  252. arr1[x].Phone = scanner.nextInt() ;
  253. System.out.println("Date Opened : ");
  254. arr1[x].Dop = scanner.nextLine() ;
  255. System.out.println("Minutes : ");
  256. arr1[x].MinsUsed = scanner.nextInt() ;
  257. System.out.println("Texts : ");
  258. arr1[x].TxtSent = scanner.nextInt() ;
  259. arr1[x].toString();
  260.  
  261.  
  262.  
  263.  
  264. }
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. public double CalculateBill()
  272. {
  273. int x=0;
  274. while (x!=i)
  275. {
  276.  
  277. System.out.println(arr1[x].CalculateBill());
  278. x++;
  279. }
  280. return x;
  281. }
  282.  
  283.  
  284. public static void Option()
  285. {
  286. int x=0;
  287.  
  288. while(x!=i)
  289. {
  290.  
  291. arr1[x].toString();
  292. x++;
  293. }
  294.  
  295. }
  296.  
  297.  
  298.  
  299. }
  300.  
  301. //end class
Add Comment
Please, Sign In to add comment