Oop
Oop
============================
using System;
namespace PRASimulation
{
class CustomerSBI
{
int id;
private string name;
double balance;
public CustomerSBI()
{
this.name = "Anonymous";
this.id = 100;
this.balance = 0.0;
}
harshad.WithDraw(100);
harshad.Deposit(200);
Inheritance
========================================
namespace PRASimulation
{
class Vehicle
{
protected int regNo;
public Vehicle(int regNo)
{
this.regNo = regNo;
}
}
class Program
{
static void Main(string[] args)
{
var car = new Car(7860, "Mahindra");
Console.WriteLine(car);
}
}
}
Method overrloading
===============================
using System;
namespace PRASimulation
{
class Calculator
{
public int Addition(int a, int b)
{
Console.WriteLine("Method 1 is executed");
return a + b;
}
class Program
{
static void Main(string[] args)
{
var adder = new Calculator();
adder.Addition(10, 20);
adder.Addition(10, 20,30);
adder.Addition(10.4f, 20);
adder.Addition(10, 20.4f);
adder.Addition(10f, 20.4f);
}
}
}
Method overriding
========================================
using System;
namespace PRASimulation
{
class YesCustomer
{
public int ID { get; set; }
public string Name { get; set; }
public double Balance { get; set; }
class Program
{
static void Main(string[] args)
{
var john = new SBICustomer(101, "John wick", 1000, "Current");
var jason = new SBICustomer(101, "Jason momoa", 500, "Savings");
if(john.WithDraw(600))
{
Console.WriteLine("{0} Balance is: {1}", john.Name, john.Balance);
}
else
{
Console.WriteLine("{0} Cannot withdraw due to minimum limit issue",
john.Name);
}
jason.Deposit(3011);
if (jason.WithDraw(600))
{
Console.WriteLine("{0} Balance is: {1}", jason.Name,jason.Balance);
}
else
{
Console.WriteLine("{0} Cannot withdraw due to minimum limit issue",
jason.Name);
}
}
}
}
namespace PRASimulation
{
class Census
{
public int ID { get; set; }
public string Name { get; set; }
static int counter { get; set; }