Guest User

Untitled

a guest
Dec 8th, 2019
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class runner {
  5. public static void rating(String brand, String series) {
  6.  
  7. }
  8.  
  9. public static void print(String brand) {
  10. System.out.println(brand);
  11. }
  12.  
  13. public static void asker(String line) {
  14. if (line == "yes") {
  15.  
  16. }
  17. }
  18.  
  19. public static String capWord(String input) {
  20. String output = input.substring(0, 1).toUpperCase() + input.substring(1);
  21. return output;
  22. }
  23.  
  24. // public void checkSeries(String findSeries, ArrayList<series> series, Scanner in) {
  25. // boolean check = false;
  26. // for (findSeries an : series) {
  27. // if (na.name.equalsIgnoreCase(series)) {
  28. // check = true;
  29. // wantedSeries = an;
  30. // }
  31. // }
  32. // }
  33.  
  34. public static void ratingOfyear(int year) {
  35. if (year == 1980) {
  36. int rating = 1;
  37. System.out.println(rating);
  38. } else if (year > 2000) {
  39. int rating = 2;
  40. System.out.println(rating);
  41. } else if (year > 2010) {
  42. int rating = 3;
  43. System.out.println(rating);
  44. } else if (year > 2020) {
  45. int rating = 4;
  46. System.out.println(rating);
  47. }
  48. }
  49.  
  50. public static void checkYear(int year, Scanner in) {
  51. while (year < 1980) {
  52. System.out.println("Car is too old");
  53. System.out.println("Please enter a new value for year:");
  54. year = in.nextInt();
  55. }
  56. if (year > 2020) {
  57. System.out.println("Car isn't even made");
  58. System.out.println("Please enter a new value for year:");
  59. year = in.nextInt();
  60. }
  61. }
  62.  
  63. public static void checkRedo(String ask, Scanner in) {
  64. while (ask.equalsIgnoreCase("yes")) {
  65. System.out.println("Please re-enter car brand");
  66. ask = in.nextLine();
  67. }
  68. if (ask.equalsIgnoreCase("no")) {
  69. System.out.println("Thank you for using.");
  70. }
  71. }
  72.  
  73. public static void main(String[] args) {
  74. Scanner asking = new Scanner(System.in);
  75. ArrayList<brands> listOfbrands = new ArrayList<brands>();
  76. brands Honda = new brands("Honda"); // Calling brands
  77. brands Tesla = new brands("Tesla");
  78. brands Toyota = new brands("Toyota");
  79. brands BMW = new brands("BMW");
  80. brands Audi = new brands("Audi");
  81. brands Empty = new brands("");
  82. series empty = new series("");
  83. series Cybertruck = new series("Cybertruck"); // Tesla
  84. series M3 = new series("M3"); // BMW index 0
  85. series M4 = new series("M4"); // BMW
  86. series M5 = new series("M5"); // BMW
  87. series X = new series("X"); // BMW
  88. series Fit = new series("Fit"); // Honda
  89. series CRV = new series("CR-V"); // Honda
  90. series Pilot = new series("Pilot"); // Honda
  91. series accord = new series("Accord"); // Honda
  92. series civic = new series("Civic"); // Honda
  93. series RAV4 = new series("RAV 4"); // Toyota
  94. series camry = new series("Camry"); // Toyota
  95. series corolla = new series("Corolla"); // Toyota
  96. series highlander = new series("High Lander"); // Toyota
  97. series A5 = new series("A5"); // Audi
  98. series A6 = new series("A6"); // Audi
  99. series A7 = new series("A7"); // Audi
  100. series Q3 = new series("Q3"); // Audi
  101. Empty.listOfSeries.add(empty);
  102. Tesla.listOfSeries.add(Cybertruck);
  103. Honda.listOfSeries.add(civic); // Honda civic
  104. Honda.listOfSeries.add(accord);
  105. Honda.listOfSeries.add(CRV);
  106. Honda.listOfSeries.add(Fit);
  107. Honda.listOfSeries.add(Pilot);
  108. Toyota.listOfSeries.add(highlander);
  109. Toyota.listOfSeries.add(corolla);
  110. Toyota.listOfSeries.add(camry);
  111. Toyota.listOfSeries.add(RAV4);
  112. BMW.listOfSeries.add(M3);
  113. BMW.listOfSeries.add(M4);
  114. BMW.listOfSeries.add(M5);
  115. BMW.listOfSeries.add(X);
  116. Audi.listOfSeries.add(A5);
  117. Audi.listOfSeries.add(A6);
  118. Audi.listOfSeries.add(A7);
  119. Audi.listOfSeries.add(Q3);
  120. listOfbrands.add(Honda);
  121. listOfbrands.add(BMW);
  122. listOfbrands.add(Toyota);
  123. listOfbrands.add(Audi);
  124. listOfbrands.add(Tesla);
  125. boolean makeCar = true;
  126. brands wantedBrand = Empty;
  127. series wantedSeries = empty;
  128. while (makeCar == true) {
  129. System.out.println("Do you want your car to be rated?");
  130. String yesorno = asking.nextLine(); // answer yes or no
  131. if (!yesorno.equalsIgnoreCase("yes")) { // if no it will end the while loop
  132. break;// ends the while loop
  133. }
  134. System.out.println("What kind of car do you have?");
  135. String brands = asking.nextLine();
  136. boolean found = false;
  137. for (brands la : listOfbrands) {
  138. if (la.name.equalsIgnoreCase(brands)) {
  139. found = true;
  140. wantedBrand = la;
  141. }
  142. if (found == false) {
  143. System.out.print(capWord(brands) + " isn't a brand ");
  144. System.out.println("thanks for using");
  145. break;
  146. }
  147. }
  148. if (found == true) {
  149. System.out.print(capWord(brands) + " is a brand and ");
  150. System.out.println("has these series avalible for this car");
  151. }
  152. for (int i = 0; i < wantedBrand.listOfSeries.size() - 1; i++) {
  153. System.out.print(wantedBrand.listOfSeries.get(i) + ", ");
  154. }
  155. System.out.println(wantedBrand.listOfSeries.get(wantedBrand.listOfSeries.size() - 1));
  156. System.out.println("What series is your car");
  157. String series = asking.nextLine();
  158. boolean checkS = true;
  159. if (checkS == true) {
  160. for (int i = 0; i < wantedBrand.listOfSeries.size();) {
  161. if (series.equalsIgnoreCase(wantedBrand.listOfSeries.get(i).toString())) {
  162. checkS = true;
  163. System.out.println("correct series");
  164. break;
  165. }
  166. }
  167. for (int o = 0; o < wantedBrand.listOfSeries.size();) {
  168. if (!series.equalsIgnoreCase(wantedBrand.listOfSeries.get(o).toString())) {
  169. checkS = false;
  170. System.out.println("wrong series");
  171. break;
  172. } break;
  173. }
  174. }
  175. System.out.println("What year is your " + brands + " " + series + ".");
  176. int year = asking.nextInt();
  177. checkYear(year, asking);
  178. ratingOfyear(year);
  179. System.out.println("Do you wish to provide additional information?");
  180. String answer = asking.nextLine();
  181. if (answer.equals("Yes")) {
  182. System.out.println("What's the hp of your " + year + brands + series);
  183. int hp = asking.nextInt();
  184. System.out.println("How many seats does your" + year + brands + series);
  185. int nSeats = asking.nextInt();
  186. }
  187. System.out.println("This is your total rating:");
  188. }
  189. asking.close();
  190. }
  191. }
RAW Paste Data