Advertisement
Guest User

Untitled

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