Class having two contructor in C#:
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassWithConstructor
{
class Program
{
static void Main(string[] args)
{
DrinkBottle db = new DrinkBottle("Pepsi", 250,"Caffetino");
db.openBottle();
Console.ReadKey();
}
}
public class DrinkBottle
{
string Brand;
int Size;
string Flavour;
string MonthOfManiFacture;
public DrinkBottle(string brand, int size, string flavour)
{
Brand=brand;
Size=size;
Flavour = flavour;
MonthOfManiFacture = DateTime.Today.ToString() ;
}
public DrinkBottle(string brand, int size, string flavour,string MFM)
{
Brand = brand;
Size = size;
Flavour = flavour;
MonthOfManiFacture = MFM;
}
public void openBottle()
{
Console.WriteLine("Specification of Bottle Opened");
Console.WriteLine("Brand:"+Brand );
Console.WriteLine("Size"+Size);
Console.WriteLine("Flavour"+Flavour);
Console.WriteLine("Manifacturing Date"+MonthOfManiFacture); }
}
}
No comments:
Post a Comment