Last active
October 3, 2018 18:44
-
-
Save PhiHuyHoang/aeedb0919f55bbd4a5ff96a45e8e6ebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Food | |
{ | |
private string name; | |
private int price; | |
private List<string> ingredient; | |
//Constructor | |
public Food(string name, int price, List<string> ingredient) | |
{ | |
this.name = name; | |
this.price = price; | |
this.ingredient = ingredient; | |
} | |
public override string ToString() | |
{ | |
return $"Food: {name}, Price: {price}" + | |
$" Ingredient: {String.Join(",", ingredient)}"; | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<Food> menu = new List<Food>(); | |
Food C = new Food("Food C", 3000, new List<string> { "ingredient C", "ingredient D" }); | |
Food D = new Food("Food D", 4000, new List<string> { "ingredient D", "ingredient E" }); | |
menu.AddRange(new List<Food> { C, D }); | |
foreach (Food f in menu) | |
{ | |
Console.WriteLine(f.ToString()); | |
} | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment