Skip to content

Commit

Permalink
Updates to the auction code so the client works.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoblenz committed Sep 5, 2019
1 parent 4090c71 commit 7ff06fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion evaluation/pilot6/auction-exercises/Auction_R5.obs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ main asset contract Auction {
-> Open(item = seller.giveItem(), bid = new Bid(new Money(0)));
}

transaction makeBid(Auction@Shared this, Bid@Owned >> Unowned newBid, Bidder@Unowned bidder) {
transaction makeBid(Auction@Shared this, Bid@Owned >> Unowned newBid, Bidder@Unowned bidder) returns Bidder@Unowned {
if (this in Open) {
if (newBid.getAmount() > bid.getAmount()) { //if the newBid is higher than the current Bid
setCurrentBid(newBid);
Expand All @@ -210,6 +210,8 @@ main asset contract Auction {
else {
revert ("Can only make a bid on an open auction.");
}

return bidder;
}

transaction setCurrentBid(Auction@Open this, Bid@Owned >> Unowned b) {
Expand Down
8 changes: 4 additions & 4 deletions evaluation/pilot6/auction-exercises/auction_client.obs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ main contract AuctionClient {
if (auction in Open) {
Bidder bidder1 = new Bidder("Bidder1", 100); // Start with $100
Bid bid1 = bidder1.createBid(10); // Bid $10 for the item
auction.makeBid(bid1, bidder1);
remote Bidder remoteBidder1 = auction.makeBid(bid1, bidder1);

Bidder bidder2 = new Bidder("Bidder2", 100);
Bid bid2 = bidder2.createBid(20);
auction.makeBid(bid2, bidder2);
remote Bidder remoteBidder2 = auction.makeBid(bid2, bidder2);

auction.finishBidding();

IO io = new IO();
io.print("bidder 1 money: ");
io.printInt(bidder1.seeMoney().getAmount());
io.printInt(remoteBidder1.seeMoney().getAmount());

io.println("");
io.print("bidder 2 money: ");
io.printInt(bidder2.seeMoney().getAmount());
io.printInt(remoteBidder2.seeMoney().getAmount());

disown bidder1;
disown bidder2;
Expand Down

0 comments on commit 7ff06fb

Please sign in to comment.