Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class runner {
- public static void rating(String brand, String series) {
- }
- public static void print(String brand) {
- System.out.println(brand);
- }
- public static void asker(String line) {
- if (line == "yes") {
- }
- }
- public static String capWord(String input) {
- String output = input.substring(0, 1).toUpperCase() + input.substring(1);
- return output;
- }
- // public void checkSeries(String findSeries, ArrayList<series> series, Scanner in) {
- // boolean check = false;
- // for (findSeries an : series) {
- // if (na.name.equalsIgnoreCase(series)) {
- // check = true;
- // wantedSeries = an;
- // }
- // }
- // }
- public static void ratingOfyear(int year) {
- if (year == 1980) {
- int rating = 1;
- System.out.println(rating);
- } else if (year > 2000) {
- int rating = 2;
- System.out.println(rating);
- } else if (year > 2010) {
- int rating = 3;
- System.out.println(rating);
- } else if (year > 2020) {
- int rating = 4;
- System.out.println(rating);
- }
- }
- public static void checkYear(int year, Scanner in) {
- while (year < 1980) {
- System.out.println("Car is too old");
- System.out.println("Please enter a new value for year:");
- year = in.nextInt();
- }
- if (year > 2020) {
- System.out.println("Car isn't even made");
- System.out.println("Please enter a new value for year:");
- year = in.nextInt();
- }
- }
- public static void checkRedo(String ask, Scanner in) {
- while (ask.equalsIgnoreCase("yes")) {
- System.out.println("Please re-enter car brand");
- ask = in.nextLine();
- }
- if (ask.equalsIgnoreCase("no")) {
- System.out.println("Thank you for using.");
- }
- }
- public static void main(String[] args) {
- Scanner asking = new Scanner(System.in);
- ArrayList<brands> listOfbrands = new ArrayList<brands>();
- brands Honda = new brands("Honda"); // Calling brands
- brands Tesla = new brands("Tesla");
- brands Toyota = new brands("Toyota");
- brands BMW = new brands("BMW");
- brands Audi = new brands("Audi");
- brands Empty = new brands("");
- series empty = new series("");
- series Cybertruck = new series("Cybertruck"); // Tesla
- series M3 = new series("M3"); // BMW index 0
- series M4 = new series("M4"); // BMW
- series M5 = new series("M5"); // BMW
- series X = new series("X"); // BMW
- series Fit = new series("Fit"); // Honda
- series CRV = new series("CR-V"); // Honda
- series Pilot = new series("Pilot"); // Honda
- series accord = new series("Accord"); // Honda
- series civic = new series("Civic"); // Honda
- series RAV4 = new series("RAV 4"); // Toyota
- series camry = new series("Camry"); // Toyota
- series corolla = new series("Corolla"); // Toyota
- series highlander = new series("High Lander"); // Toyota
- series A5 = new series("A5"); // Audi
- series A6 = new series("A6"); // Audi
- series A7 = new series("A7"); // Audi
- series Q3 = new series("Q3"); // Audi
- Empty.listOfSeries.add(empty);
- Tesla.listOfSeries.add(Cybertruck);
- Honda.listOfSeries.add(civic); // Honda civic
- Honda.listOfSeries.add(accord);
- Honda.listOfSeries.add(CRV);
- Honda.listOfSeries.add(Fit);
- Honda.listOfSeries.add(Pilot);
- Toyota.listOfSeries.add(highlander);
- Toyota.listOfSeries.add(corolla);
- Toyota.listOfSeries.add(camry);
- Toyota.listOfSeries.add(RAV4);
- BMW.listOfSeries.add(M3);
- BMW.listOfSeries.add(M4);
- BMW.listOfSeries.add(M5);
- BMW.listOfSeries.add(X);
- Audi.listOfSeries.add(A5);
- Audi.listOfSeries.add(A6);
- Audi.listOfSeries.add(A7);
- Audi.listOfSeries.add(Q3);
- listOfbrands.add(Honda);
- listOfbrands.add(BMW);
- listOfbrands.add(Toyota);
- listOfbrands.add(Audi);
- listOfbrands.add(Tesla);
- boolean makeCar = true;
- brands wantedBrand = Empty;
- series wantedSeries = empty;
- while (makeCar == true) {
- System.out.println("Do you want your car to be rated?");
- String yesorno = asking.nextLine(); // answer yes or no
- if (!yesorno.equalsIgnoreCase("yes")) { // if no it will end the while loop
- break;// ends the while loop
- }
- System.out.println("What kind of car do you have?");
- String brands = asking.nextLine();
- boolean found = false;
- for (brands la : listOfbrands) {
- if (la.name.equalsIgnoreCase(brands)) {
- found = true;
- wantedBrand = la;
- }
- if (found == false) {
- System.out.print(capWord(brands) + " isn't a brand ");
- System.out.println("thanks for using");
- break;
- }
- }
- if (found == true) {
- System.out.print(capWord(brands) + " is a brand and ");
- System.out.println("has these series avalible for this car");
- }
- for (int i = 0; i < wantedBrand.listOfSeries.size() - 1; i++) {
- System.out.print(wantedBrand.listOfSeries.get(i) + ", ");
- }
- System.out.println(wantedBrand.listOfSeries.get(wantedBrand.listOfSeries.size() - 1));
- System.out.println("What series is your car");
- String series = asking.nextLine();
- boolean checkS = true;
- if (checkS == true) {
- for (int i = 0; i < wantedBrand.listOfSeries.size();) {
- if (series.equalsIgnoreCase(wantedBrand.listOfSeries.get(i).toString())) {
- checkS = true;
- System.out.println("correct series");
- break;
- }
- }
- for (int o = 0; o < wantedBrand.listOfSeries.size();) {
- if (!series.equalsIgnoreCase(wantedBrand.listOfSeries.get(o).toString())) {
- checkS = false;
- System.out.println("wrong series");
- break;
- } break;
- }
- }
- System.out.println("What year is your " + brands + " " + series + ".");
- int year = asking.nextInt();
- checkYear(year, asking);
- ratingOfyear(year);
- System.out.println("Do you wish to provide additional information?");
- String answer = asking.nextLine();
- if (answer.equals("Yes")) {
- System.out.println("What's the hp of your " + year + brands + series);
- int hp = asking.nextInt();
- System.out.println("How many seats does your" + year + brands + series);
- int nSeats = asking.nextInt();
- }
- System.out.println("This is your total rating:");
- }
- asking.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement