Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. package com.Adams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9.  
  10. System.out.println("Enter your auctionId ");
  11. Scanner vehicleAuctionID = new Scanner(System.in);
  12. String auctionId = vehicleAuctionID.nextLine();
  13.  
  14. System.out.println("Enter the vehicule description");
  15. Scanner vehicleDescriptionInput = new Scanner(System.in);
  16. String vehicleDescription = vehicleDescriptionInput.nextLine();
  17.  
  18. System.out.println("What is the reserve price");
  19. Scanner vehicleReserPriceInput = new Scanner(System.in);
  20. int resevePrice = vehicleReserPriceInput.nextInt();
  21.  
  22.  
  23. VehicleAuction newVehicleAuction = new VehicleAuction(auctionId, vehicleDescription, resevePrice);
  24.  
  25.  
  26. // Define an array of VehicleAuction references named auctions,
  27. // which can be used to store up to 20 VehicleAuction objects.
  28.  
  29. VehicleAuction auctions[] = new VehicleAuction[20];
  30. for (int i = 0; i < auctions.length; i++) {
  31.  
  32. auctions[i] = new VehicleAuction(auctionId, vehicleDescription, resevePrice);
  33. }
  34.  
  35.  
  36. int auctionCount = 0;
  37.  
  38.  
  39. do {
  40.  
  41.  
  42. System.out.printf("***** Auction System Menu *****");
  43. System.out.printf("%n" + "A. " + "Add New Vehicle Auction");
  44. System.out.printf("%n" + "B. " + "Display All Vehicle Auctions");
  45. System.out.printf("%n" + "C. " + "Submit Bid for Vehicle");
  46. System.out.printf("%n" + "D. " + "List Ended Vehicle Auctions");
  47. System.out.printf("%n" + "X. " + "Exit the program");
  48. System.out.printf("%n" + "Enter your selection: ");
  49.  
  50. Scanner console = new Scanner(System.in);
  51. String selection = console.nextLine();
  52.  
  53.  
  54. switch (selection.toUpperCase()) {
  55. case "A": {if (auctionId.equals(newVehicleAuction.getAuctionID()) ){
  56. System.out.println("Your Auction ID is already registered");
  57. break;
  58. }else {
  59.  
  60. System.out.println("Adding new Vehicle Auction");
  61.  
  62.  
  63. break;
  64. }}
  65. case "B": {
  66. System.out.println("Display all Vehicle Auctions");
  67. //Display all vehicle auctions
  68. for(int i = 0 ; i <= auctions.length -1; i++){
  69. System.out.println(auctions[i]);
  70. }
  71.  
  72. break;
  73. }
  74. case "C": {
  75. System.out.println("Submit bid for Vehicle Auction");
  76. //Submit Bid for Vehicle
  77. newVehicleAuction.getCurrentBid();
  78. break;
  79. }
  80. case "D": {
  81. System.out.println("List of ended Vehicle Auctions");
  82. //List ended vehicle auctions
  83. newVehicleAuction.isSold();
  84. break;
  85. }
  86. case "X": {
  87. System.out.println("You are now exiting this program, Thank you!");
  88.  
  89. System.exit(0);
  90.  
  91.  
  92. }
  93. default:
  94. System.out.printf("That is not a valid response. Try Again.");
  95.  
  96. }
  97.  
  98.  
  99. } while (auctionCount <= 20);
  100.  
  101. System.out.println("We can only accept 20 auctions");
  102. newVehicleAuction.printDetails();
  103.  
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement