Guest User

Untitled

a guest
Apr 28th, 2019
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.ArrayList;
  3. import java.util.*;
  4. import java.io.*;
  5. import java.util.InputMismatchException;
  6. public class Login extends Apartment_Rental{
  7. private String username;
  8. private String password;
  9. public Apartment_Records ar = new Apartment_Records();
  10. public Tenant_Records tr = new Tenant_Records();
  11. public Billing bill = new Billing();
  12. public Reports rep = new Reports();
  13.  
  14. public Login() {
  15.  
  16. System.out.println("\t\tFESOLA APARTMENT RENTAL\n");
  17. this.username = "adminlog";
  18. this.password = "1234";
  19. }
  20.  
  21. public void setUsername(String username){
  22. username = username;
  23. }
  24.  
  25. public String getUsername(){
  26. return username;
  27. }
  28.  
  29. public void setPassword(String password){
  30. password = password;
  31. }
  32.  
  33. public String getPassword(){
  34. return password;
  35. }
  36.  
  37. public void adLogin(){
  38. Scanner sc = new Scanner(System.in);
  39. int t = 0, option = 0;
  40. System.out.println("\t[LOG IN]");
  41.  
  42. for(int x = 0; x==0;){
  43. System.out.print("\tUsername:\t");
  44. String uname = sc.nextLine().trim();
  45. System.out.print("\tPassword:\t");
  46. String pword = sc.nextLine().trim();
  47.  
  48.  
  49. if(username.equals(uname)&&password.equals(pword)){
  50. for(int xxx=0; xxx==0;){
  51. System.out.println("\n\t[MAIN MENU]");
  52.  
  53.  
  54. System.out.println("\t[1] APARTMENT RECORDS\n\t[2] TENANT RECORDS\n\t[3] BILLING\n\t[4] REPORTS\n\t[5] EXIT");
  55. for(int xx=0; xx==0;){
  56. while(t==0){
  57. try{
  58.  
  59. System.out.print("\tEnter choice:\t");
  60. option = sc.nextInt();
  61. break;}
  62. catch(Exception e){
  63. System.out.println("\tINVALID INPUT!");
  64. System.out.println();
  65. sc.next();
  66. t=0; }}
  67.  
  68. if(option <= 5 || option >= 1){
  69. switch(option){
  70. case 1: //apartment records
  71. Apartment_Records ar = new Apartment_Records();
  72.  
  73. for(int xxxx = 0; xxxx==0;){
  74. ar.menuApartment();
  75. System.out.println("\n\tBack to Apartment Records Menu? [1] yes [2] no");
  76. while(t==0){
  77. try{
  78. System.out.print("\tEnter choice:\t");
  79. option = Integer.parseInt(sc.nextLine());
  80. break;}
  81. catch(Exception e){
  82. System.out.println("\tINVALID INPUT!");
  83.  
  84. t=0; } }
  85. if(option==1){
  86. xxxx = 0;
  87. }else{
  88. System.out.println("\n");
  89. xxxx=1;
  90. xxx = 0;
  91. }
  92.  
  93. }
  94.  
  95. break;
  96. case 2: //tenant records
  97.  
  98. for(int xxxx = 0; xxxx==0;){
  99. tr.menuTenant();
  100. System.out.println("\n\tBack to Tenant Records Menu? [1] yes [2] no ");
  101. while(t==0){
  102. try{
  103. System.out.print("\tEnter choice:\t");
  104. option = sc.nextInt();
  105. break;}
  106. catch(Exception e){
  107. System.out.println("\tINVALID INPUT!");
  108. System.out.println();
  109. sc.next();
  110. t=0; }}
  111.  
  112.  
  113. if(option==1){
  114. xxxx = 0;
  115. }else{
  116. System.out.println("\n");
  117. xxxx=1;
  118. xxx = 0;
  119. }
  120. }
  121. break;
  122. case 3: //billing
  123. for(int xxxx = 0; xxxx==0;){
  124. bill.billing();
  125. System.out.println("\n\tBack to Billing? [1] yes [2] no");
  126. while(t==0){
  127. try{
  128. System.out.print("\tEnter choice:\t");
  129. option = Integer.parseInt(sc.nextLine());
  130. break;}
  131. catch(Exception e){
  132. System.out.println("\tINVALID INPUT!");
  133.  
  134. t=0; } }
  135. if(option==1){
  136. xxxx = 0;
  137. }else{
  138. System.out.println("\n");
  139. xxxx=1;
  140. xxx = 0;
  141. }
  142.  
  143. }
  144. break;
  145. case 4: //reports
  146. for(int xxxx = 0; xxxx==0;){
  147. rep.menuReports();
  148. System.out.println("\n\tBack to Reports Records Menu? [1] yes [2] no ");
  149. while(t==0){
  150. try{
  151. System.out.print("\tEnter choice:\t");
  152. option = sc.nextInt();
  153. break;}
  154. catch(Exception e){
  155. System.out.println("\tINVALID INPUT!");
  156. System.out.println();
  157. sc.next();
  158. t=0; }}
  159.  
  160.  
  161. if(option==1){
  162. xxxx = 0;
  163. }else{
  164. System.out.println("\n");
  165. xxxx=1;
  166. xxx = 0;
  167. }
  168. }
  169. break;
  170. case 5: //exit
  171. System.out.print("\t\nExit...");
  172. System.exit(0);
  173. break;
  174. }
  175.  
  176. xx=1;}
  177. else if(option==6){
  178. System.out.println("\tINVALID INPUT!"); xx=0; }}
  179.  
  180. x=1;}
  181.  
  182.  
  183. }else{
  184. System.out.println("\n\tIncorrect username and password. Try Again.\n");
  185. x=0; }}
  186.  
  187.  
  188.  
  189. } }
Add Comment
Please, Sign In to add comment