Complete Methods Implementation
//Demo on Complete Methods Implementation
using System;
namespace FreshersLike
{
class Institute
{
public string CourseName;
public decimal Fees, Discount;
public Institute( string cname , decimal fees )
{
CourseName = cname;
Fees = fees;
Discount = 0;
}
public void ShowCourse()
{
Console.WriteLine("Course Name : {0} \nFees : Rs. {1} \nDiscount : Rs. {2} ", CourseName,Fees , Discount);
}
public void GetDiscount(decimal Percentage, out decimal Discount)
{
Discount = Percentage * 10;
}
public void SetCourseFees(ref decimal Fees, decimal discount)
{
Fees -= discount;
}
}
class CompleteMethodImplementation
{
public static void Main()
{
Institute freshers_net = new Institute(".NET Package", 4900);
Console.WriteLine("Freshers Like Institute Details : ");
freshers_net .ShowCourse();
decimal percentage;
Console.Write("Enter your percentage : ");
percentage = decimal.Parse(Console.ReadLine());
freshers_net.GetDiscount(percentage, out freshers_net.Discount);
Console.WriteLine("Congrats , You have got a discount of Rs. {0} ", freshers_net.Discount );
freshers_net.SetCourseFees(ref freshers_net.Fees, freshers_net.Discount);
Console.WriteLine("Final Course Fees will be Rs. {0} ", freshers_net.Fees );
}
}
}
0 comments:
Post a Comment