Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Exam_Preparation1
- {
- public class Employee
- {
- private string name;
- private double salary;
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- if(value.Length < 3)
- {
- throw ArgumentException("Invalid name");
- }
- name = value;
- }
- }
- private Exception ArgumentException(string v)
- {
- throw new NotImplementedException();
- }
- public double Salary
- {
- get
- {
- return salary;
- }
- set
- {
- if(value < 560)
- {
- throw ArgumentException("Invalid salary");
- }
- salary = value;
- }
- }
- public Employee(string name, double salary)
- {
- Name = name;
- Salary = salary;
- }
- public override string ToString()
- {
- //обект на стринг
- //Employee: < име > with salary < заплата >
- return $"Employee: {name} with salary {salary:F2}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement