-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathmain.go
39 lines (32 loc) · 1.09 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package onlineauctionsystem
import (
"fmt"
"time"
)
func Run() {
auctionSystem := GetInstance()
// Register users
user1 := NewUser("1", "John Doe", "[email protected]")
user2 := NewUser("2", "Jane Smith", "[email protected]")
auctionSystem.RegisterUser(user1)
auctionSystem.RegisterUser(user2)
// Create auction listings
listing1 := NewAuctionListing("1", "Item 1", "Description 1", 100.0, 60*time.Second, user1)
listing2 := NewAuctionListing("2", "Item 2", "Description 2", 50.0, 120*time.Second, user2)
auctionSystem.CreateAuctionListing(listing1)
auctionSystem.CreateAuctionListing(listing2)
// Search auction listings
searchResults := auctionSystem.SearchAuctionListings("Item")
fmt.Println("Search Results:")
for _, listing := range searchResults {
fmt.Println(listing.ItemName)
}
// Place bids
bid1 := NewBid("1", user2, 150.0)
bid2 := NewBid("2", user1, 200.0)
auctionSystem.PlaceBid(listing1.ID, bid1)
auctionSystem.PlaceBid(listing1.ID, bid2)
// Wait for a while to see the auction close
time.Sleep(65 * time.Second)
fmt.Printf("Auction 1 status: %v\n", listing1.Status)
}