我让我的程序运行,但我似乎无法输出我拥有的存储信息。当我运行程序时,所有的行都是空白的。代码还有更多内容,但我认为这是程序用于输出信息的主要代码。
class Display
{
public static void Main(string[] args)
{
LandlinePhone yourHomePhone = new LandlinePhone("VTech", "V-4321", "219-999-2345", true);
Console.WriteLine("Manufacturer: {0}", yourHomePhone.Manufacturer);
Console.WriteLine("Model: {0}", yourHomePhone.Model);
Console.WriteLine("Phone Number: {0}", yourHomePhone.PhoneNumber);
Console.WriteLine("Cordless: {0}", (yourHomePhone.HasCord ? "Yes" : "No"));
}
{
class LandlinePhone : Telephone
{
private bool hasCord;
public LandlinePhone()
{
}
public LandlinePhone(string manufacturer, string model, string phoneNumber, bool hasCord)
: base(manufacturer, model, phoneNumber)
{
hasCord = HasCord;
}
public bool HasCord
{
get
{
if (hasCord == true)
{
return true;
}
else
{
return false;
}
}
set
{
hasCord = value;
}
}
new public void display()
{
base.display();
Console.WriteLine(HasCord ? "Cordless: Yes" : "Cordless: No");
}
}
class Telephone
{
public bool isConnected = true;
public string lastNumberDialed;
private string manufacturer;
private string model;
private string phoneNumber;
public Telephone()
{
}
public Telephone(string manufacturer, string model, string phoneNumber)
{
}
public string Manufacturer
{
get
{
return manufacturer;
}
set
{
manufacturer = value;
}
}
public string Model
{
get
{
return model;
}
set
{
model = value;
}
}
public string PhoneNumber
{
get
{
return phoneNumber;
}
set
{
phoneNumber = value;
}
}
public void display()
{
Console.WriteLine();
Console.WriteLine("Manufacturer: {0}", Manufacturer);
Console.WriteLine("Model: {0}", Model);
Console.WriteLine("Phone Number: {0}", PhoneNumber);
}