Professional Documents
Culture Documents
задача
задача
задача
using System.Runtime.CompilerServices;
namespace Products
{
class Program
{
static void Main(string[] args)
{
Product product = new Product();
product.name = "Pencils";
product.price = 25.25m;
product.quantity = 50;
Console.WriteLine(product.ToString());
using System;
using System.Collections.Generic;
using System.Text;
namespace Products
{
public class Product
{
public string name;
public int quantity;
public decimal price;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
public int Quantity
{
get { return this.quantity; }
set { this.quantity = value; }
}
public decimal Price
{
get { return this.price; }
set { this.price = value; }
}
public Product()
{
}
public Product(string name, int quantity, decimal price)
{
this.name = name;
this.quantity = quantity;
this.price = price;
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Products
{
public class StoreManager
{
public List<Product> newproducts { get; set; }
public StoreManager()
{
newproducts = new List<Product>();
}
public void AddProduct(Product product)
{
newproducts.Add(product);
}
public Product GetTheMostExpensiveProduct()
{
Product product = new Product();
foreach (Product item in newproducts)
{
if (item.price > product.price)
{
product = item;
}
}
return product;
}
}
}