public void eatSandwich(Sandwich sandwichToEat) { if (sandwichToEat.name == favoriteSandwich.name) { Console.WriteLine("delicious"); } else { Console.WriteLine("gross"); } }
public void eatSandwich(Sandwich sandwichToEat) { if (sandwichToEat.name == favoriteSandwich.name) { Console.WriteLine("Delcious sandwich!! Wow!!"); } else { Console.WriteLine("That sandwich sucked"); } }
static void Main(string[] args) { // # Lightning Exercise One // 1. Create a new dictionary of to represent a sandwich. The dictionary should store the follow data: // - Bread type // - Price // - Number of calories // - A comma-seperated, stringified list of ingridients // Dictionary<string, string> sandvich = new Dictionary<string, string>(){ // {"Bread type", "French"}, // {"Price", "1.99"} // }; Sandwich tuna = new Sandwich("tuna", 1.99, 150); tuna.breadType = "white"; tuna.price = 1.99; tuna.getTotalCalories(3); tuna.name = "tuna"; tuna.IngredientList = new List <string>() { "Bread", "Mayo", "Tuna" }; Sandwich PBJ = new Sandwich("Peanut butter and jelly", 1.50, 100); PBJ.breadType = "white"; PBJ.price = 1.50; PBJ.getTotalCalories(4); PBJ.name = "Peanut butter and jelly"; PBJ.IngredientList = new List <string>() { "Bread", "Peanut Butter", "Jelly" }; // # Lightning Exercise Two // 1. Create a new class that represents a customer at the sandwich shop // 2. Give the customer the following public properties: // - FirstName (string) // - LastName (string) // - RewardPoints (int) // - Email (string) // 3. In the `Main()` method of your `Program` class, create a list of customers. // 4. Print each customer's first name and last name to the console. Customer dude = new Customer("Jeff", "Lebowski", "*****@*****.**"); dude.rewardPoints = 0; dude.favoriteSandwich = tuna; dude.eatSandwich(tuna); Customer metal = new Customer("Nathan", "Explosion", "*****@*****.**"); metal.rewardPoints = 666; metal.favoriteSandwich = PBJ; metal.eatSandwich(tuna); metal.AddRewardPoints(100); List <Customer> customerList = new List <Customer>() { metal, dude }; customerList.ForEach(customer => Console.WriteLine($"{customer.firstName} {customer.lastName}")); { } }
static void Main(string[] args) { // Lightning Exercise One // 1. Create a new dictionary to represent a sandwich. The dictionary should store the follow data: // - Bread type // - Price // - Number of calories // - A comma-seperated, stringified list of ingridients // Dictionary<string, string> sandwich = new Dictionary<string, string>(){ // {"breadType", "wheat"}, // {"price", "7.99"} // }; // sandwich.Add("numberOfCalories", "400"); // sandwich.Add("ingredientList", "Pickles, Turkey, Cheese"); Sandwich tuna = new Sandwich("Tuna", 6.99, 150); tuna.breadType = "pumpernickel"; tuna.getTotalCalories(4); tuna.IngredientList = new List <string>() { "Tuna", "Pickles", "Lettuce", "Cucumber" }; Sandwich rueben = new Sandwich("Rueben", 9.99, 250); rueben.breadType = "white"; List <Sandwich> sandwichList = new List <Sandwich>() { tuna, rueben }; sandwichList.ForEach(sandwich => Console.WriteLine(sandwich.breadType)); Customer Tommy = new Customer("Tommy", "Spurlock", "*****@*****.**") { RewardsPoints = 1000, favoriteSandwich = rueben }; Customer Josh = new Customer("Josh", "Havey", "*****@*****.**") { RewardsPoints = 4000, favoriteSandwich = tuna }; Josh.eatSandwich(tuna); Tommy.eatSandwich(tuna); List <Customer> customerDataBase = new List <Customer>() { Josh, Tommy }; Console.WriteLine(Josh.RewardsPoints); Josh.addRewardsPoints(100); }