/* * Bryan * Fitness Menu */ using System; using System.Collections.Generic; namespace bryan_FitnessMenu { public class Drink { public string Flavor { get; set; } public double Price { get; set; } = 0.00; public string Size { get; set; } public List<string> Extras { get; set; } = new List<string>(); /// <summary> /// Converts the drink into a receipt /// </summary> /// <returns></returns> public override string ToString() { /* 20oz Fruit Energy Boost Price: $6.50 */ string formatted = $"{this.Size} {this.Flavor}{Environment.NewLine}"; // Add any extras if (this.Extras.Count > 0) foreach (string _extra in this.Extras) formatted += $" {_extra}{Environment.NewLine}"; // Add the price formatted += $" Price: {this.Price:c}{Environment.NewLine}---{Environment.NewLine}"; return formatted; } /// <summary> /// Calculate the price for this drink /// </summary> public void CalculatePrice() { // If we call this before we've set anything... if (this.Size == null) return; // Handle Size switch (this.Size) { case "20oz": this.Price = 4.00; break; case "16oz": this.Price = 3.50; break; default: this.Price = 3.00; break; } // Handle the extras this.Price += this.Extras.Count * 2.50; } } }