16# Constructors Object Oriented Programming
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace darklter
{
class Product
{
public Product()
{
[Link]("Product Created");
}
}
}
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Product p1 = new Product();
Product p2 = new Product();
Product p3 = new Product();
}
}
}
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace darklter
{
class Product
{
public string name;
public float price;
}
}
///////////////
//[Link]//
//\\\\\\\\\\\\\
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace darklter
{
class Student
{
public string firstName;
public string lastName;
public int grade;
public char section;
public Student(string firstName, string lastName, int grade, char section)
{
[Link] = firstName;
[Link] = lastName;
[Link] = grade;
[Link] = section;
[Link]("Student Created");
[Link](firstName + " " + lastName);
[Link](grade + " - " + section);
}
}
}
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Product p1 = new Product();
[Link] = "Milk";
[Link] = 150;
Product p2 = new Product();
[Link] = "Milk";
[Link] = 150;
}
}
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////
using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Student s1 = new Student("David", "Sdpt", 5, 'E');
Student s2 = new Student("Alenere", "Sdpt", 6, 'A');
}
}
}
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace darklter
{
class Product
{
public string name;
public float price;
public Product(string name,float price)
{
[Link] = name;
[Link] = price;
}
}
}
///////////////
//[Link]//
//\\\\\\\\\\\\
using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Product p1 = new Product("Mik",150);
Product p2 = new Product("Coke",75);
Product p3 = new Product("Sprite", 75);
Product p4 = new Product("Royal", 75);
[Link]("Product Name : " + [Link]);
[Link]("Product Price : " + [Link]);
}
}
}
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||
using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
[Link]("Name : ");
string n = [Link]();
[Link]("Voiceline : ");
string vl = [Link]();
[Link]();
Character c = new Character(n, vl);
Character c1 = new Character("lester Pogi","Tang Ina Mo Rin");
}
}
class Character
{
public string name;
public string voiceLine;
public Character(string name,string voiceLine)
{
[Link] = name;
[Link] = voiceLine;
[Link](name + " : " + voiceLine);
}
}
}