Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Trailers {
- public static Scanner scanner = new Scanner(System.in);
- public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- public static String question;
- public static int smallTrailer = 5;
- public static String costumerName;
- public static String[] namesSmallTrailer = {"", "", "", "", ""};
- public static int i = 0;
- public static void smallTrailerAvaible() {
- System.out.println("there are " + smallTrailer + " small trailers avaible");
- }
- static void costumersNames() throws IOException {
- int number = 1;
- for (int i = 0; i < 5; i++) {
- System.out.println("Small trailer " + number + " " + namesSmallTrailer[i]);
- number++;
- }
- }
- public static void smallTrailers() throws IOException {
- System.out.println("Name of costumer");
- namesSmallTrailer[i] = reader.readLine();
- if (namesSmallTrailer.equals("")) {
- System.out.println("Please enter name");
- }
- int weight = 750;
- System.out.println("What is the weight of the load (in kg)?");
- int weightSmall = scanner.nextInt();
- int optimalWeight = weightSmall - weight;
- if(weightSmall >weight)
- {
- System.out.println("Warning! The maximum load (750 kg) is exceeded by " + optimalWeight + " kg!");
- }
- System.out.println("Are you sure y/n");
- question =scanner.next();
- if(question.equals("y"))
- {
- if (smallTrailer >= 5) {
- System.out.println("there are no trailers avaible");
- } else {
- smallTrailer = smallTrailer - 1;
- i++;
- }
- }
- if(question.equals("n"))
- {
- namesSmallTrailer[i] = "";
- }
- }
- static void largeTrailers() {
- }
- static void Overview() throws IOException {
- costumersNames();
- smallTrailerAvaible();
- }
- static void exitMenu() {
- System.exit(0);
- }
- public void menu() throws IOException {
- char quit = 'n';
- String input;
- int choise = 0;
- Scanner scanner = new Scanner(System.in);
- boolean a = true;
- while (a) {
- System.out.println("******************************************");
- System.out.println("* Trailer rental");
- System.out.println("******************************************");
- System.out.println("* 1) Rent small trailer 1");// 5
- System.out.println("* 2) Rent large trailer"); // 3
- System.out.println("* 3) Overview"); // арендованые
- System.out.println("* 9) Exit");
- System.out.println("******************************************");
- System.out.println(" Select an option:");
- choise = scanner.nextInt();
- switch (choise) {
- case 1:
- smallTrailers();
- break;
- case 2:
- largeTrailers();
- break;
- case 3:
- Overview();
- break;
- case 9:
- exitMenu();
- default:
- System.out.println("Choose between 1,2 or 9");
- }
- }
- }
- public static void main(String[] args) throws IOException {
- new Trailers().menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement