In: Computer Science
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp4
{
public class Pizza
{
public double Diameter
{
get;
set;
}
public string Name
{
get;
set;
}
public string Supplier
{
get;
set;
}
public Pizza()
{
Diameter = 10;
Name = "DefaultName";
Supplier = "DefaultSupplier";
}
public Pizza(double diameter, string name, string supplier)
{
Diameter = diameter;
Name = name;
Supplier = supplier;
}
public bool IsLargePizza()
{
if(Diameter > 15)
return true;
else
return false;
}
public override string ToString()
{
return Name +" is a large pizza supplied by "+ Supplier +".";
}
public string ToString(string bestBefore)
{
return Name +" is a large pizza supplied by "+ Supplier+". It is best before "+ bestBefore+".";
}
}
}
public class Test
{
public static void Main()
{
Pizza p = new Pizza();
p.Name = "Margherita";
p.Diameter = 16;
p.Supplier = "Dominos";
Console.WriteLine(p.ToString());
Console.WriteLine(p.ToString("six
hours after delivery"));
Console.WriteLine("It is large
Pizza : "+p.IsLargePizza());
}
}
Output:
Margherita is a large pizza supplied by Dominos. Margherita is a large pizza supplied by Dominos. It is best before six hours after delivery. It is large Pizza : True
Do ask if any doubt.