sources
This commit is contained in:
parent
1d0a2964cf
commit
151d77ee54
11 changed files with 340 additions and 0 deletions
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue