private FlowLayoutPanel createPanel(BookEntry book, bool isFooter) { FlowLayoutPanel panel = new FlowLayoutPanel(); panel.FlowDirection = FlowDirection.LeftToRight; panel.Height = PANELHEIGHT; panel.Width = PANELWIDTH; Label title = new Label(); title.Width = TITLEWIDTH; if (!isFooter) { title.Text = "Title: "; } title.Text += book.getTitle(); title.Anchor = AnchorStyles.Left; panel.Controls.Add(title); Label quantity = new Label(); quantity.Width = QUANTITYWIDTH; if (isFooter) { quantity.Text = "Total quantity is: "; } else { quantity.Text = "Quantity: "; } quantity.Text += book.getQuantity().ToString(); quantity.Anchor = AnchorStyles.Left; panel.Controls.Add(quantity); totalQuantity += book.getQuantity(); Label price = new Label(); price.Width = PRICEWIDTH; if (isFooter) { price.Text = "Total price is: "; } else { price.Text = "Price: "; } price.Text += (book.getPrice() * book.getQuantity()).ToString(); price.Anchor = AnchorStyles.Left; panel.Controls.Add(price); totalPrice += book.getPrice(); return(panel); }
// If the books have the same title, add their quantities and return true // Else return false public bool addQuantities(BookEntry book) { if (!this.title.Equals(book.getTitle())) { return(false); } this.quantity += book.getQuantity(); return(true); }