Classes:
public class TechnicalInformation
{
public double SizeMB { get; set; }
public string OperatingSystem { get; set; }
public TechnicalInformation(double sizeMb, string operatingSystem)
{
SizeMB = sizeMb;
OperatingSystem = operatingSystem;
}
}
public class DigitalProduct
{
public string Name { get; set; }
public double Price { get; set; }
public TechnicalInformation TechnicalInformation { get; set; }
public DigitalProduct(string name, double price, TechnicalInformation technicalInformation)
{
Name = name;
Price = price;
TechnicalInformation = technicalInformation;
}
public void show_details()
{
Console.WriteLine($"Product: {Name}");
Console.WriteLine($"Price: ${Price:F2}");
Console.WriteLine($"Size: {TechnicalInformation.SizeMB:F2}");
Console.WriteLine($"Compatible with: {TechnicalInformation.OperatingSystem}");
}
}
Instância:
TechnicalInformation technicalInformation = new TechnicalInformation(1500, "Windows/mac");
DigitalProduct product = new DigitalProduct("Photoshop", 89.99, technicalInformation);
product.show_details();