Tag: javalangreflectArray

package com.troels.bicycle; import java.lang.reflect.Array; import java.util

  • package com.troels.bicycle;

  •  

  • import java.lang.reflect.Array;

  • import java.util.Arrays;

  • import java.util.Scanner;

  •  

  • public class Main {

  •  

  •     public static String stringInput = “”;

  •     public static int intInput = 0;

  •  

  •     public static void main(String[] args) {

  •         createBicycle();

  •     }

  •  

  •     public static void createBicycle() {

  •         Bicycle bicycle = new Bicycle();

  •         Scanner sc = new Scanner(System.in);

  •  

  •         color(bicycle, sc);

  •         gears(bicycle, sc);

  •         wheelSize(bicycle, sc);

  •         System.out.println(“Your bicycle is ” + bicycle.color + “, has ” + bicycle.gears + ” gears, and has a wheel size of ” + bicycle.wheelSize + “!”);

  •     }

  •  

  •     public static void color(Bicycle bicycle, Scanner sc) {

  •         System.out.println(“Which color should the bicycle be?”);

  •         stringInput = sc.nextLine().toLowerCase();

  •         if (bicycle.isValidColor(stringInput) == true) {

  •             bicycle.color = stringInput;

  •             //System.out.println(“Bicycle is now ” + bicycle.color);

  •         } else {

  •             System.out.println(stringInput + ” is not a valid color! You can choose between these colors: ” + Arrays.asList(bicycle.colors).toString());

  •             color(bicycle, sc);

  •         }

  •     }

  •  

  •     public static void gears(Bicycle bicycle, Scanner sc){

  •         System.out.println(“How many gears should the bicycle have?”);

  •         intInput

  • Read More