Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SoftUniiii
- {
- class Student
- {
- private string name;
- public static int count = 0;
- public static decimal money = 0;
- public static void Info()
- {
- Console.WriteLine($"There are {count} students.");
- Console.WriteLine($"Money: {money}");
- }
- public void AddMoney(decimal m)
- {
- money += m;
- }
- public void GetMoney(decimal m)
- {
- if (money < m)
- {
- throw new Exception("Not enough money!");
- }
- money -= m;
- }
- public Student(string name)
- {
- this.Name = name;
- count++;
- }
- public void PrintInfo()
- {
- Console.WriteLine($"Hi, I'm {this.Name}.");
- Console.WriteLine($"We are {count} students!");
- }
- public string Name
- {
- get { return this.name; }
- set { this.name = value; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement