Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE1322L Assignment 2 - Spring 2023 Introduction: In this weeks assignment youll write software for an auction company. Your program will allow the auction company

CSE1322L Assignment 2 - Spring 2023 Introduction: In this weeks assignment youll 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. Ie, 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, itll 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 returns the next possible lowest bid. This is the currentBid + the bidIncrement. Create an override of toString (Java) or ToString (C#) 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 youll write a number of methods in your driver class: Write a method getNextLot. This will take in an ArrayList (Java) or List (C#) 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 (C#) 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 ArrayList/List 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 its 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 (C#) of Lots Define a currentLot of type Lot and set it to null. Using a loop youll 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 dont have a lot yet (currentLot is null or its description is Unknown 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 its not sold 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 lots description is Unknown Item 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 lots descriptions is Unknown Item, 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 (C#) of Lot called auction. Call mainMenu passing it the auction collection.

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions