This commit is contained in:
Alexander Zhirov 2023-02-27 01:22:09 +03:00
parent 1d0a2964cf
commit 151d77ee54
11 changed files with 340 additions and 0 deletions

View file

@ -0,0 +1,39 @@
class Contact
{
string bgColor()
{
return "Серый";
}
}
class Friend : Contact
{
string currentBgColor = "Светло-зеленый";
string currentReminder;
this(ref string c)
{
currentBgColor = c;
}
override string bgColor()
{
return currentBgColor;
}
string reminder()
{
return currentReminder;
}
}
unittest
{
string startColor = "Синий";
Friend f = new Friend(startColor);
Contact c = f; // Подставить экземпляр класса Friend вместо экземпляра класса Contact
auto color = c.bgColor(); // Вызвать метод класса Friend
import std.stdio : writeln;
writeln(color);
}