public Bid(int clientMadeBid, AuctionItem onItem, float forAmount) { //creates a new bidding object that a client made on an item (onItem) with an ammount (forAmount) m_ClientID = clientMadeBid; m_Item = onItem; m_Amount = forAmount; }
public Bid(AuctionItem onItem, float forAmount) { //creates a bid object without client id stores item bid reflects and ammount (typically starting amount) m_ClientID = -1; m_Item = onItem; m_Amount = forAmount; }
public AuctionItemList() { //creates and initializes auction items //read xml file and get auction item information XmlDocument doc = new XmlDocument(); doc.Load(URLString); XmlElement root = doc.DocumentElement; XmlNodeList setOnodes = root.SelectNodes("item"); int id = 0; string description = ""; string imagePath = ""; float startBid = 0; DateTime closeTime; Random r = new Random(); this.listOItems = new LinkedList<AuctionItem>(); foreach (XmlNode node in setOnodes) { try { id = Int32.Parse(node["id"].InnerText); description = node["description"].InnerText; imagePath = node["imagePath"].InnerText; startBid = float.Parse(node["startBid"].InnerText); //generates random closing time double minuteAddition = (double)(r.NextDouble() + r.Next(2, 6)); minuteAddition = .5; closeTime = DateTime.Now.AddMinutes(minuteAddition); AuctionItem newItem = new AuctionItem(id, description, closeTime, startBid, imagePath); this.listOItems.AddLast(newItem); } catch (FormatException fe) { //if either id or startBid to not parse tell server System.Windows.Forms.MessageBox.Show("FormatException in AuctionItemList constructor by: " + fe.TargetSite + "\rwith: " + fe.Message); } catch (ArgumentNullException ane) { System.Windows.Forms.MessageBox.Show("ArgumentNullException in AuctionItemList constructor by: " + ane.TargetSite + "\rwith: " + ane.Message); } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Exception in AuctionItemList constructor by: " + e.TargetSite + "\rwith: " + e.Message); } } }
public bool addAuctionItemToList(int id, string description, float startingBid, string imagePath) { try { //attempts to add auction item to list //NOTE DOES NOT PERSIST ITEM //first checks if item id is already used LinkedListNode<AuctionItem> node = listOItems.First; int i = listOItems.Count; while (i > 0) { if (node.Value.getItemID() == id) { //if item id found return false return false; } else { node = node.Next; i--; } } Random r = new Random(); //generate random closing time double minuteAddition = (double)(r.NextDouble() + r.Next(2, 6)); DateTime closeTime = DateTime.Now.AddMinutes(minuteAddition); //create item add it to list and return true AuctionItem newItem = new AuctionItem(id, description, closeTime, startingBid, imagePath); this.listOItems.AddFirst(newItem); return true; } catch (Exception e) { //if any exception occcurs return false return false; } }