我是多态的新手并且有点挣扎。
我有三个班。作为基类的访问类。然后是送货和取货。
送货和取货都是拜访。
我希望能够参考访问课程并与送货和取货交谈。
public virtual class Visit
{
private string customerName;
private string customerAddress;
private DateTime arrivalTime;
public string customername
{
//name properties
set { customerName = value; }
get { return customerName; }
}
public string customeraddress
{
//address properties
set { customerAddress = value; }
get { return customerAddress; }
}
public DateTime arrivaltime
{
//time proerties
set { arrivalTime = value; }
get { return arrivalTime; }
}
}
public class Delivery : Visit
/*
* Polymorphism, Delivery is also a visit.
*/
{
private string deliveryAddress;
private string deliveryName;
public string deliveryaddress
{
set { deliveryAddress = value; }
get { return deliveryAddress; }
}
public string deliveryname
{
set { deliveryName = value; }
get { return deliveryName; }
}
public string ToString()
{ //return Delivery details
return deliveryname + " " + deliveryaddress + " " + customername + " " + customeraddress + " " + arrivaltime;
}
}
public class Pickup : Visit
/*
* Polymorphism, pickup is also a visit.
*/
{
public string ToString()
{ //return Pickup details
return customername + " " + customeraddress + " " + arrivaltime.ToString();
}
}
}