static void Main(string[] args) { // Sharpie Set // Reuse your Sharpie class // Create SharpieSet class // it contains a list of Sharpie // Add method CountUsable() -> sharpie is usable if it has ink in it // Add method RemoveTrash() -> removes all unusable sharpies SharpieSet sharpieSet = new SharpieSet(new List <Sharpie>()); var sharpie1 = new Sharpie(1, "blue", 100, 100, true, "sharpie1"); var sharpie2 = new Sharpie(1, "green", 100, 100, true, "sharpie2"); var sharpie3 = new Sharpie(1, "red", 100, 100, true, "sharpie3"); var sharpie4 = new Sharpie(1, "yellow", 100, 100, true, "sharpie4"); sharpieSet.sharpieList.Add(sharpie1); sharpieSet.sharpieList.Add(sharpie2); sharpieSet.sharpieList.Add(sharpie3); sharpieSet.sharpieList.Add(sharpie4); sharpie1.Use(); sharpie3.Use(); sharpieSet.CountUsable(sharpieSet.sharpieList); sharpieSet.RemoveTrash(sharpieSet.sharpieList); sharpieSet.PrintOutSharpieList(sharpieSet.sharpieList); Console.ReadLine(); }
public void RemoveTrash() { for (int i = 0; i < SetOfSharpies.Count; i++) { Sharpie sharpie = SetOfSharpies[i]; if (sharpie.InkAmount <= 0) { SetOfSharpies.Remove(sharpie); i--; } } }
static void Main(string[] args) { Sharpie red = new Sharpie("red", 0.3f); Sharpie blue = new Sharpie("blue", 0.2f); SharpieSet mySharpies = new SharpieSet(); mySharpies.Add(red); mySharpies.Add(blue); mySharpies.CountUsable(); for (int i = 0; i < 100; i++) { red.Use(); } mySharpies.CountUsable(); mySharpies.RemoveTrash(); }
static void Main(string[] args) { var sharpieOne = new Sharpie("blue", 1); var sharpieTwo = new Sharpie("red", 0.5); var sharpieThree = new Sharpie("purple", 1); var setOne = new SharpieSet(); setOne.Add(sharpieOne); setOne.Add(sharpieTwo); setOne.Add(sharpieThree); for (int i = 0; i < 100; i++) { sharpieOne.Use(); } Console.WriteLine($"Number of usable sharpies: {setOne.CountUsable()}"); setOne.RemoveTrash(); }
// Sharpie Set // Reuse your Sharpie class // Create SharpieSet class // it contains a list of Sharpie // Add method CountUsable() -> sharpie is usable if it has ink in it // Add method RemoveTrash() -> removes all unusable sharpies static void Main(string[] args) { var first = new Sharpie("Black", 6); var second = new Sharpie("White", 7); first.Use(); second.Use(); //Console.WriteLine(second.InkAmount); var newlist = new SharpieSet(); //newlist.Sharpies.Add(new Sharpie("White", 4)); newlist.Sharpies.Add(first); newlist.Sharpies.Add(second); Console.WriteLine(newlist.CountUsable()); //Console.WriteLine(newlist.RemoveTrash()); Console.ReadLine(); }
public void Add(Sharpie sharpie) { SetOfSharpies.Add(sharpie); }
public void Add(Sharpie sharpie) { SharpList.Add(sharpie); }
public static void AddSharpieToList(Sharpie sharpie) { Sharpies.Add(sharpie); }