Classe Person:
namespace exercise84.Models;
internal class Person
{
public string Name { get; }
public int Age { get; }
public Person(string name, int age)
{
Name = name;
Age = age;
}
}
Classe VipCustomer:
namespace exercise84.Models;
internal class VipCustomer : Person
{
public string Level { get; }
public string VipCode { get; }
public VipCustomer(string name, int age, string level, string vipCode)
: base(name, age)
{
Level = level;
VipCode = vipCode;
}
public override string ToString()
{
return $"Welcome, VIP customer: {Name}\nAge: {Age}\nLevel: {Level}\nVIP Code: {VipCode}\n";
}
}
Instâncias:
using exercise84.Models;
VipCustomer cliente1 = new VipCustomer("Renata", 32, "Gold", "VIP123A");
VipCustomer cliente2 = new VipCustomer("Leonardo", 40, "Diamond", "VIP789X");
Console.WriteLine(cliente1);
Console.WriteLine(cliente2);