Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by baitap3_dh ( 5 years ago )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BaiTap
{
abstract public class Xe
{
public Xe()
{
}
public string myName
{
get
{
return contents;
}
set
{
contents = value;
}
}
private string contents;
abstract public void Who();
//{
// Console.WriteLine("Tôi là xe: {0}", contents);
//}
}
public class Xe_Toyota : Xe
{
public Xe_Toyota(string Toyotacontents) : base()
{
this.Toyotacontents = Toyotacontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Toyotacontents);
}
public string myName
{
get
{
return Toyotacontents;
}
set
{
Toyotacontents = value;
}
}
private string Toyotacontents;
}
public class Xe_Dream : Xe
{
public Xe_Dream(string Dreamboxcontents) : base()
{
this.Dreamboxcontents = Dreamboxcontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Dreamboxcontents);
}
public string myName
{
get
{
return Dreamboxcontents;
}
set
{
Dreamboxcontents = value;
}
}
private string Dreamboxcontents;
}
public class Xe_Spacy : Xe
{
public Xe_Spacy(string Spacycontents) : base()
{
this.Spacycontents = Spacycontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Spacycontents);
}
public string myName
{
get
{
return Spacycontents;
}
set
{
Spacycontents = value;
}
}
private string Spacycontents;
}
public class Xe_BMW : Xe
{
public Xe_BMW(string BMWcontents) : base()
{
this.BMWcontents = BMWcontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", BMWcontents);
}
public string myName
{
get
{
return BMWcontents;
}
set
{
BMWcontents = value;
}
}
private string BMWcontents;
}
public class Xe_Fiat : Xe
{
public Xe_Fiat(string Fiatcontents) : base()
{
this.Fiatcontents = Fiatcontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Fiatcontents);
}
public string myName
{
get
{
return Fiatcontents;
}
set
{
Fiatcontents = value;
}
}
private string Fiatcontents;
}
public class Xe_Dulich : Xe
{
public Xe_Dulich(string Dulichcontents) : base()
{
this.Dulichcontents = Dulichcontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Dulichcontents);
}
public string myName
{
get
{
return Dulichcontents;
}
set
{
Dulichcontents = value;
}
}
private string Dulichcontents;
}
public class Xe_May : Xe
{
public Xe_May(string Maycontents) : base()
{
this.Maycontents = Maycontents;
}
public override void Who()
{
//base.Who();
Console.WriteLine("Tôi là xe: {0}", Maycontents);
}
public string myname
{
get
{
return Maycontents;
}
set
{
Maycontents = value;
}
}
private string Maycontents;
}
class Program
{
static void Main(string[] args)
{
Xe[] xeco = new Xe[7];
xeco[0] = new Xe_Toyota("Toyota");
xeco[1] = new Xe_Dream("Dream");
xeco[2] = new Xe_Spacy("Spacy");
xeco[3] = new Xe_BMW("BMW");
xeco[4] = new Xe_Fiat("Fiat");
xeco[5] = new Xe_Dulich("Dulich");
xeco[6] = new Xe_May("May");
for (int i = 0; i < 7; i++)
{
xeco[i].Who();
}
Console.ReadLine();
}
}
}
Revise this Paste