Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PersonProgram
- {
- class Program
- {
- static void Main(string[] args)
- {
- Person p1 = new Person(30000);
- Console.WriteLine("Person Salary: " + p1.Salary);
- p1.Salary = 40000;
- Console.WriteLine("Person Salary: " + p1.Salary);
- Student s1 = new Student()
- {
- PocketMoney = 600
- };
- Console.WriteLine("Student PocketMoney: " + s1.PocketMoney);
- s1.SpendMoney(100);
- Console.WriteLine("Student PocketMoney: " + s1.PocketMoney);
- Console.ReadLine();
- }
- }
- class Person
- {
- private double basicSalary;
- public double Salary { get { return basicSalary; } set { basicSalary = value; } }
- public Person()
- {
- basicSalary = 2000;
- }
- public Person(double Salary)
- {
- basicSalary = Salary;
- }
- }
- class Student : Person
- {
- public double PocketMoney { get; set; }
- public void SpendMoney(double Money)
- {
- PocketMoney -= Money;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement