Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java please In this week's assignment you'll write software for an auction company. Your program will allow the auction company to enter Lots of

In Java please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this week's assignment you'll write software for an auction company. Your program will allow the auction company to enter "Lots" of items for sale. A Lot is either one item, or a bunch of items which are being sold together. Each item has a starting price, and a bid increment. For example an item may start off as $100, with a bid increment of $25, which means the next lowest amount someone can bid is $125, then $150 etc. People can of course bid more than the bid increment. An auction can have as many items as they want, but only one item will be available to bid at any given time. Tasks: - Begin by creating a class called Lot - It must have private attributes for lotNumber (int), description (string), currentBid (int). bidincrement (int), sold (boolean). - Each lot will be sequentially numbered starting at 1001. - Write a default constructor which sets: lotNumber to the next sequential number. le, the first object of type Lot should have a lotNumber of 1001, the next object should be 1002 , then 1003 etc. The person creating the object will not need to pass this value in, it'll be calculated in the class itself. Description should be set to "Unknown Item" currentBid and bidincrement should both be set to 0 . sold should be set to false. - Write an overloaded constructor that takes in a description, startingBid and bidincrement. Again, the lotNumber should be automatically calculated, just like in the default constructor. The description, currentBid and bidincrement should be set to the parameters passed in - sold should be set to false. - Create a method markSold, which sets Sold to true - Create a getter method for sold, bidincrement, and description - Create a setter method for currentBid - Create a method nextBid which retums the next possible lowest bid. This is the currentBid + the bidincrement. - Create an override of toString (Java) or ToString (CH) If the lot is sold (check the boolean), return a string like: - "Lot 1001. Description was sold for $500 " If the lot is not sold, return a string like: - "Lot 1001. Description current bid $100 minimum bid $120 In both cases Lot 1001 should be the actual lot number, the description should replace the word Description and the current bid/sold amount should be the current bid, and the minimum bid should be the nextBid. Next you'll write a number of methods in your driver class: - Write a method getNextL.ot. This will take in an ArrayList (Java) or List (CH) of Lots. It should return a Lot If the auction ArrayList/List has items in it, return the first item (from cell 0 ) and remove it from the ArrayList/List. Otherwise return an empty Lot created using the default constructor. - Write a method additem This will take in an ArrayList (Java) or List (CH) of lots It will return void It will prompt the user for a new Description, starting bid, and bid increment, then create a lot and add it to the ArrayListList that was passed in. - Write a method bid - This will take in a Lot - Ask the user how much they want to bid, and tell them the minimum bid they must make. - Read in the users bid If it's too small (below the minimum bid) tell them. Otherwise change the current bid for this Lot item to the amount they bid. - Create a method markSold This will take in a Lot Mark the lot as sold Print out the current Lot - Create a method mainMenu This will take in an ArrayList (Java) or List (CH) of Lots Define a currentLot of type Lot and set it to null. Using a loop you'll print out the menu until the user chooses option 5. If you currently have a Lot to bid on, print Current Lot: Followed by the description of the lot. If you don't have a lot yet (currentL.ot is null or if's description is "Uniknown Item"), print "We are not currently bidding" Next print the menu: - 1. Add Lot to Auction - 2. Start bidding on next Lot - 3. Bid on current Lot - 4. Mark current Lot sold - 5. Quit Read in the users choice - If the user chooses 1 use the appropriate method to add an item to the auction. - If the user chooses 2, first check that there are Lots in the auction. If there are currently none print "There is nothing to bid on, add an item first" If you have a current lot, and it's not soid print "You must mark the current lot as sold before bringing up the next Lot* Otherwise get the next lot and store it in currentLot. - If the user chooses 3 and the current lot is null, or the current lot's description is "Unknown ltem" or the current lot is sold print: You must first bring a Lot up for bidding" Otherwise, allow the user to bid - If the user chooses 4 and the current lot is null or the current lot's descriptions is "Unknown ltem", or the current lot is sold print: "You must first bring a Lot up for Bidding" Otherwise, mark the current lot as sold - Your main method should simple create an ArrayList (Java) or List (CA) of Lot called auction. Call mainMenu passing it the auction collection. Example Runs: [User input in red] We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 1 What is the description of this item 65- Samsung OLED TV What is the starting bid 350 What is the bid increment 25 We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 1 What is the description of this item Desk Lamp What is the starting bid 5 What is the bid increment 5 We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 1 What is the description of this item Gamer Chair, red with armrests. What is the starting bid 100 What is the bid increment 10 We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 3 You must first bring a Lot up for bidding We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 4 You must first bring a Lot up for bidding We are not currently bidding 1. Add Lot to Auction 2. Start bidding on next Lot 3. Bid on current Lot 4. Mark current Lot Sold 5. Exit 2 Current Lot

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions