ababin 3a5571dfe7 Добавить 'README.md' | 5 mesi fa | |
---|---|---|
bin | 5 mesi fa | |
obj | 5 mesi fa | |
ConsoleApp3.csproj | 5 mesi fa | |
ConsoleApp3.sln | 5 mesi fa | |
Program.cs | 5 mesi fa | |
README.md | 5 mesi fa |
namespace ClassLibrary1
{
public class Instrument
{
public string name { get; set; }
public int price { get; set; }
}
}
using ClassLibrary1;
var guitar = new Instrument
{
name = "gibson",
price = 2000
};
Console.WriteLine(guitar.name);
Вывод:
gibson
Type myType = typeof(Guitar);
Console.WriteLine(myType.ToString());
Console.ReadLine();
public class Guitar
{
public string Name { get; set; }
public int Gstrings { get; set; }
public Guitar(string n, int a)
{
Name = n;
Gstrings = a;
}
public void Display()
{
Console.WriteLine($"Название: {Name} Количество струн: {Gstrings}");
}
public decimal Payment(int quantity, decimal price)
{
return quantity * price;
}
}
class Instrument
{
public string Name { get; set; }
public string Brand { get; set; }
public decimal Price { get; set; }
}
class Guitar : Instrument
{
public int StringsNumber { get; set; }
public string BodyMaterial { get; set; }
}
class MusicStore
{
public List<Instrument> Instruments { get; set; }
public MusicStore()
{
Instruments = new List<Instrument>();
}
public void AddInstrument(Instrument instrument)
{
Instruments.Add(instrument);
}
public static decimal GetPriceWithInterest(Guitar guitar, int percent, int years)
{
for (int i = 0; i < years; i++)
{
guitar.Price += guitar.Price / 100 * percent;
}
return guitar.Price;
}
}
class Program
{
static void Main(string[] args)
{
var guitar = new Guitar { Name = "Stratocaster", Brand = "Fender", Price = 1000, StringsNumber = 6, BodyMaterial = "Alder" };
var store = new MusicStore();
store.AddInstrument(guitar);
var priceWithInterest = MusicStore.GetPriceWithInterest(guitar, 6, 100);
Console.WriteLine($"Цена гитары с процентами составляет: {priceWithInterest:C}");
Console.ReadLine();
}
}