All pastes #475507 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-05-07 14:07 UTC
rendered paste body
import java.util.*;/** *  Testing class for the Vehicle and Driver class *   *  @author Audrey Quah *  @version 6 May 2007 */ public class FalseTest{        public static void main(String args[])        {                                 // Testing manual user input generated vehicle            createVehicle(false);                        // then following this, how do i make this loop theo? as in after it creates one vehicle,             //   it'll ask the user whether or not he still wants to create another vehicle UNTIL the user types in no        }                private static void createVehicle(boolean secondVehicle)        {                     Scanner nScanner = new Scanner(System.in);                        if (secondVehicle)                System.out.println("Do you want to create another vehicle? (Just enter y or n)");            else                System.out.println("Do you want to create a vehicle? (Just enter y or n)");            System.out.println("y: yes");            System.out.println("n: no");            try            {                String answer = nScanner.next();                                if(!answer.equals("y") && !answer.equals("n"))                {                    System.out.println("Invalid user input. Please reenter choice.");                    createVehicle(secondVehicle);                    return;                }                                if(answer.equals("y"))                {                    Vehicle v1 = new Vehicle();                    // Offer the Creation of a new Vehicle                    System.out.println("Vehicle Created");                    createVehicle(true);                }                else                {                    System.out.println("No vehicle created");                }                            }            catch (InputMismatchException e)            {                System.out.println("Invalid user input. Please reenter choice.");                createVehicle(secondVehicle);            }           }           }