Advertisement
Ivan_Bochev

Application

Jun 17th, 2021 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.21 KB | None | 0 0
  1. package c;
  2.  
  3. import java.util.*;
  4.  
  5. public class Application {
  6.     private static double budget;
  7.  
  8.     public static double getBudget() {
  9.         return budget;
  10.     }
  11.  
  12.     public static void setBudget(double budget) {
  13.         Application.budget = budget;
  14.     }
  15.  
  16.     public static boolean validBudget(double budget) {
  17.         if (budget < 0) {
  18.             System.out.println("\nInvalid budget!\nPlease try again!");
  19.         } else if (budget < 30) {
  20.             System.out.println("\nYour budget should be over 30 $!");
  21.         } else {
  22.             return true;
  23.         }
  24.         return false;
  25.     }
  26.  
  27.     public static void main(String[] args) {
  28.         Scanner sc = new Scanner(System.in);
  29.         MetalConcerts concert1 = new MetalConcerts("Metallica", "thrash metal, heavy metal", 170, 10);
  30.         MetalConcerts concert2 = new MetalConcerts("Megadeth", "thrash metal, heavy metal", 180, 10);
  31.         MetalConcerts concert3 = new MetalConcerts("Black Veil Brides", "hard rock, glam metal, heavy metal", 120, 10);
  32.         MetalConcerts concert4 = new MetalConcerts("Opeth", "death metal, progressive metal", 125, 10);
  33.         MetalConcerts concert5 = new MetalConcerts("Deep Purple", "heavy metal, hard rock", 90, 10);
  34.         MetalConcerts concert6 = new MetalConcerts("Pantera", "groove metal, heavy metal, glam metal", 210, 10);
  35.         MetalConcerts concert7 = new MetalConcerts("Arch Enemy", "melodic death metal, death metal", 90, 10);
  36.         MetalConcerts concert8 = new MetalConcerts("Cannibal Corpse", "death metal", 80, 10);
  37.         MetalConcerts concert9 = new MetalConcerts("Mayhem", "black metal", 65, 10);
  38.         MetalConcerts concert10 = new MetalConcerts("Lamb of God", "groove metal, heavy metal", 135, 10);
  39.         RockConcerts concert11 = new RockConcerts("Blink-182", "pop punk, alternative rock, punk rock", 110, 10);
  40.         RockConcerts concert12 = new RockConcerts("Ramones", "punk rock, pop punk", 100, 10);
  41.         RockConcerts concert13 = new RockConcerts("Sex Pistols", "punk rock", 95, 10);
  42.         RockConcerts concert14 = new RockConcerts("Kiss", "hard rock, glam metal, heavy metal", 150, 10);
  43.         RockConcerts concert15 = new RockConcerts("Green Day", "punk rock, alternative rock", 230, 10);
  44.         RockConcerts concert16 = new RockConcerts("Scorpions", "hard rock, heavy metal", 30, 10);
  45.         RockConcerts concert17 = new RockConcerts("System Of A Down", "hard rock, nu metal, alternative metal", 240,
  46.                 10);
  47.         RockConcerts concert18 = new RockConcerts("Nirvana", "grunge rock, alternative rock", 70, 10);
  48.         RockConcerts concert19 = new RockConcerts("Pearl Jam", "hard rock, grunge rock, alternative rock", 270, 10);
  49.         RockConcerts concert20 = new RockConcerts("Alice In Chains",
  50.                 "grunge rock, alternative metal, hard rock, heavy metal", 40, 1);
  51.  
  52.         ArrayList<Concert> Aconcerts = new ArrayList<>(Arrays.asList(concert1, concert2, concert3, concert4, concert5,
  53.                 concert6, concert7, concert8, concert9, concert10, concert11, concert12, concert13, concert14,
  54.                 concert15, concert16, concert17, concert18, concert19, concert20));
  55.  
  56.         ArrayList<String> Agenres = new ArrayList<>(Arrays.asList("heavy metal", "thrash metal", "alternative metal",
  57.                 "nu metal", "black metal", "glam metal", "death metal", "melodic death metal", "progressive metal",
  58.                 "groove metal", "hard rock", "alternative rock", "punk rock", "grunge rock", "pop punk"));
  59.  
  60.         while (true) {
  61.             try {
  62.                 System.out.println("\n1. Buy ticket\n2. Leave the program");
  63.                 System.out.print("\nWhat is your choice: ");
  64.                 int choice = Integer.parseInt(sc.nextLine());
  65.                 if (choice == 2) {
  66.                     break;
  67.                 }
  68.                 switch (choice) {
  69.                 case 1:
  70.                     System.out.print("\nWhat's your age: ");
  71.                     int age = Integer.parseInt(sc.nextLine());
  72.                     if (age > 0 && age < 16) {
  73.                         System.out.println("\nYou're not old enough to get ticket!");
  74.                     } else if (age >= 16 && age <= 100) {
  75.                         System.out.print("What is your budget: ");
  76.                         budget = Double.parseDouble(sc.nextLine());
  77.                         new Hall("Sofia, 'Unak' Stadium", Aconcerts, Agenres);
  78.                         if (validBudget(budget)) {
  79.                             Hall.sellTickets();
  80.                         }
  81.                     } else {
  82.                         System.out.println("\nInvalid age!\nPlease try again!");
  83.                     }
  84.                     break;
  85.                 default:
  86.                     System.out.println("\nInvalid choice!\nPlease try again!");
  87.                 }
  88.             } catch (NumberFormatException nfe) {
  89.                 System.out.println("\nInvalid input!");
  90.             }
  91.         }
  92.         sc.close();
  93.     }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement