Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Adams;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("Enter your auctionId ");
- Scanner vehicleAuctionID = new Scanner(System.in);
- String auctionId = vehicleAuctionID.nextLine();
- System.out.println("Enter the vehicule description");
- Scanner vehicleDescriptionInput = new Scanner(System.in);
- String vehicleDescription = vehicleDescriptionInput.nextLine();
- System.out.println("What is the reserve price");
- Scanner vehicleReserPriceInput = new Scanner(System.in);
- int resevePrice = vehicleReserPriceInput.nextInt();
- VehicleAuction newVehicleAuction = new VehicleAuction(auctionId, vehicleDescription, resevePrice);
- // Define an array of VehicleAuction references named auctions,
- // which can be used to store up to 20 VehicleAuction objects.
- VehicleAuction auctions[] = new VehicleAuction[20];
- for (int i = 0; i < auctions.length; i++) {
- auctions[i] = new VehicleAuction(auctionId, vehicleDescription, resevePrice);
- }
- int auctionCount = 0;
- do {
- System.out.printf("***** Auction System Menu *****");
- System.out.printf("%n" + "A. " + "Add New Vehicle Auction");
- System.out.printf("%n" + "B. " + "Display All Vehicle Auctions");
- System.out.printf("%n" + "C. " + "Submit Bid for Vehicle");
- System.out.printf("%n" + "D. " + "List Ended Vehicle Auctions");
- System.out.printf("%n" + "X. " + "Exit the program");
- System.out.printf("%n" + "Enter your selection: ");
- Scanner console = new Scanner(System.in);
- String selection = console.nextLine();
- switch (selection.toUpperCase()) {
- case "A": {if (auctionId.equals(newVehicleAuction.getAuctionID()) ){
- System.out.println("Your Auction ID is already registered");
- break;
- }else {
- System.out.println("Adding new Vehicle Auction");
- break;
- }}
- case "B": {
- System.out.println("Display all Vehicle Auctions");
- //Display all vehicle auctions
- for(int i = 0 ; i <= auctions.length -1; i++){
- System.out.println(auctions[i]);
- }
- break;
- }
- case "C": {
- System.out.println("Submit bid for Vehicle Auction");
- //Submit Bid for Vehicle
- newVehicleAuction.getCurrentBid();
- break;
- }
- case "D": {
- System.out.println("List of ended Vehicle Auctions");
- //List ended vehicle auctions
- newVehicleAuction.isSold();
- break;
- }
- case "X": {
- System.out.println("You are now exiting this program, Thank you!");
- System.exit(0);
- }
- default:
- System.out.printf("That is not a valid response. Try Again.");
- }
- } while (auctionCount <= 20);
- System.out.println("We can only accept 20 auctions");
- newVehicleAuction.printDetails();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement