47 lines
681 B
Plaintext
47 lines
681 B
Plaintext
class Animal
|
|
{
|
|
str type;
|
|
str name;
|
|
int age;
|
|
|
|
fn copy() Animal
|
|
{
|
|
Animal cp = new Animal;
|
|
cp.type = this.type;
|
|
cp.name = this.name;
|
|
cp.age = this.age;
|
|
|
|
return cp;
|
|
}
|
|
}
|
|
|
|
Animal a = new Animal;
|
|
a.type = "Cow";
|
|
a.name = "Buryatka";
|
|
a.age = 5;
|
|
|
|
Animal b = a.copy();
|
|
b.name = "Gavryusha";
|
|
b.age = 10;
|
|
|
|
printline(a);
|
|
printline(b);
|
|
|
|
printline("Types are same:");
|
|
printline(a.type == b.type);
|
|
|
|
printline("Names are NOT the same");
|
|
printline(a.name != b.name);
|
|
|
|
printline("1st age less than 2nd");
|
|
printline(a.age < b.age);
|
|
|
|
if (a.type == b.type && a.name != b.name && a.age < b.age)
|
|
printline("Test passed");
|
|
else
|
|
{
|
|
printline("Test failed");
|
|
exit(1);
|
|
}
|
|
|