Bug fix
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
Fruit[] na=new Fruit[2];
na[0]=new Fruit("xyz","white",0.00);
na[1]=new Apple("xyz","black",5.75);
Console.WriteLine(na[0].price);
Console.WriteLine(na[1].color);
}
}
class Fruit
{
string fruitname;
public string color;
public double price;
//Add Constructer
public Fruit(string name, string color,double price)
{
name = fruitname;
this.color = color;
this.price = price;
}
}
class Apple : Fruit
{
//string color;
public Apple(string name, string color,double price):base(name,color,price)
{
//Base(name);
this.color = color;
}
}
class NZApple : Apple
{
//double price;
public NZApple(string name, string color, double price):base(name,color,price)
{
this.price = price;
}
}
}
0 件のコメント:
コメントを投稿