Scenario description and detailed requirements for particular methods behaviour
User.observe(a : Auction)
Creates observedAuction link to the a auction. Before this – checks if the auction is not linked already to avoid duplicates.
User.createAuction(aName : String, aDesc : String, cPrice : Integer, minPrice : Integer, eTime : Date, cat : Category, rLimit : Integer) : Auction
Creates new Auction object, filling its respective mandatory attributes (aName, aDesc, cPrice, minPrice, eTime, rLimit), and linking it to the target user (self) and category provided as a parameter (cat). Return the object created.
The auction starts at the current time.
User.getNotifications(from : Date, till : Date) : String [0..*]
Returns a collection of strings, each formulated as one of the following (only the events dated between from and till are to be included):
New bid in your auction <auctionName> placed on <bid_date>. Current price <amount>
Your auction <auctionName> ended - winning offer by <userName> at price <amount>
Your auction <auctionName> ended with no sufficient bid placed.
You won auction <auctionName> with price <amount>
(the greyed – out segments are to be implemented later – if time allows) User.getNewSubscribedCategoriesItems(since : Date) : Auction [0..*]
Returns a collection of Auctions that belong to the categories connected by a subscribedCategory link to the current User and that began after the since date.
User.subscribe(c : Category)
Creates subscribedCategory link to the c category. Before this – checks if the category is not linked already to avoid duplicates.
Bid.cancel(reason : String)
Set optional fields for this Bid object – cancelReason and cancelingDate (the latter using the current date read from system).
Auction.placeBid(bidder : User, maxPrice : Integer) : Boolean
Check if the User’s rating is greater or equal to ratingLimit. If not – return false;
Otherwise, create a Bid object, filling its date and price fields with current system date and maxPrice parameter values respectively. Connect this object with bidder link to the User and with auction link to the Auction.
Invoke the winningBid() method and calculate the result to be returned. If the result is equal to the currently created Bid object AND the price offered matches the Auction’s minimum price – return true. Otherwise return false.
Auction.winningBid() : Bid [0..1]
Select the bids that are not cancelled and sort them according to their dates and then – according to their price (descending) return the first item as the operation’s result.
Auction.prolong(till : Date)
Check if the new till date is indeed later than the one currently set. If so – update the endDate field.
Auction.cancel()
Check if the current date is earlier than Auction’s endDate. If so, do the following:
for each Bid placed invoke its cancel operation setting “Auction cancelled by seller”.
Auction.calculateCharge() : Real
Calculate the base value as the maximum of minimumPrice and calledPrice. If the value is lower than 5 – return 0.2, if lower than 20 – return 0.8, if lower than 100 – return 5, otherwise – return base * 0.04.
Auction.resolve()
Invoke the winningBid operation to determine the best bid. If a non-empty result was returned, check if its price is higher than the minimumPrice of the Auction. If so, create a Purchase object and connect it with its links to buyer (retrieved from the Bid). Connect the Auction’s result link to the Purchase created.
Auction.sellersOtherItems() : Auction [0..*]
Determine the current date.
Then return the result of the query that navigates from auction to the seller and from it – back to the Auction using the offer link, selecting only those auctions whose endDate is later than the current date.
Purchase.settle()
Set the refused field to true. Decrease the buyer’s rating by 20. Then, Follow the algorithm like in Auction.winningBid() : Bid [0..1], but here additionally filter out from the result the bid or bids by the refusing buyer.
If another satisfactory bid is determined this way – create the Purchase object for respective user – analogously like in Auction.resolve().
Purchase.leaveBuyerFeedback(rt : Integer, com : string) : Boolean
Check if the buyerFeedback link already contains some Feedback. If so – return false.
Otherwise – create respective Feedback object, provide values of its fields from parameters and connect it to the Purchase with the buyerFeedback link.
Update the rating field of the seller (you need to determine the proper object by navigating through the Auction) by the value of the rating (it is expected to be 1 for “positive”, 0 for “neutral”, or -1 for
“negative”). Return true.
Purchase.leaveSellerFeedback(rt : Integer, com : string) : Boolean
Perform the steps for the buyer and sellerFeedback link analogously like in case of the above method leaveBuyerFeedback. The only structural difference is that determining the buyer object is more straightforward, as it is directly linked to the Purchase object.
AuctionSite.registerUser(uName : String, rName : String, pass : String, mail : String) : Boolean
check in the user property for existence of an object that already contains userName equal to the uName parameter – if found, return false.
check in the user property for existence of an object that already contains email equal to the mail parameter – if found, return false.
Otherwise, create a User objects filling its fields with respective parameters and store it in the user property. Return true.
AuctionSite.setAuction(cName : String, aName : String, aDesc : String, cPrice : Integer, mPrice : Integer, eTime : Date, uName : String) : Boolean