using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace VienKhoaHoc { public enum Certificate { TienSi = 0, ThacSi, CuNhan, KySu, CaoDang, TrungCap, KyThuatVien } //******************************** public enum Position { GiamDoc =0, PhoGiamDoc, TruongPhong, PhoPhong, } //******************************** class NhanVien { protected String hoten; protected int namsinh; protected Certificate bangcap; public NhanVien() { hoten = "Chua co ten"; namsinh = 1900; bangcap = Certificate.KyThuatVien; } public NhanVien(String hoten, int namsinh, Certificate bangcap) { this.hoten = hoten; this.namsinh = namsinh; this.bangcap = bangcap; } public override string ToString() { return hoten + "," + namsinh + "," + bangcap.ToString(); } public void Nhap() { Console.Write("Nhap ho ten:"); hoten = Console.ReadLine(); Console.Write("Nhap nam sinh:"); namsinh = int.Parse(Console.ReadLine()); Console.WriteLine("Nhap mot so cua bang cap nhu sau:"); foreach (Certificate value in Enum.GetValues(typeof(Certificate))) Console.WriteLine("{0}.{1}",(int)value, value.ToString()); bangcap = (Certificate)int.Parse(Console.ReadLine()); } public float TinhLuong() { return 0; } } //******************************** class NhaKhoaHoc : NhanVien { private Position chucvu; private int sobaibao; private int songaycong; private float bacluong; public NhaKhoaHoc():base() { chucvu = Position.PhoPhong; sobaibao = 0; songaycong = 0; bacluong = 0; } public NhaKhoaHoc (String ht, int ns, Certificate bc, Position cv, int sbb, int snc, int bl):base(ht,ns,bc) { chucvu = cv; sobaibao = sbb; songaycong = snc; bacluong = bl; } public override string ToString() { return "[" + base.ToString() + "," + chucvu.ToString() + "," + sobaibao + "," + songaycong + "," + bacluong + "," + TinhLuong() + " trieu dong" + "]"; } public new void Nhap() { base.Nhap(); Console.WriteLine("Nhap mot so cua chuc vu nhu sau:"); foreach (Position value in Enum.GetValues(typeof(Position))) Console.WriteLine("{0}.{1}", (int)value, value.ToString()); chucvu = (Position)int.Parse(Console.ReadLine()); Console.Write("Nhap so bai bao:"); sobaibao = int.Parse(Console.ReadLine()); Console.Write("Nhap so cong:"); songaycong = int.Parse(Console.ReadLine()); Console.Write("Nhap bac luong: "); bacluong = float.Parse(Console.ReadLine()); } public new float TinhLuong() { return ((2 * bacluong) / 26) * songaycong; //2 trieu VND } } //******************************** class NhaQuanLy : NhanVien { private Position chucvu; private int songaycong; private float bacluong; public NhaQuanLy():base() { chucvu = Position.PhoPhong; songaycong = 0; bacluong = 0; } public NhaQuanLy (String ht, int ns, Certificate bc, Position cv, int snc, int bl):base(ht,ns,bc) { chucvu = cv; songaycong = snc; bacluong = bl; } public override string ToString() { return "[" + base.ToString() + "," + chucvu.ToString() + "," + songaycong + "," + bacluong + "," + TinhLuong() + " trieu dong" + "]"; } public new void Nhap() { base.Nhap(); Console.WriteLine("Nhap mot so cua chuc vu nhu sau:"); foreach (Position value in Enum.GetValues(typeof(Position))) Console.WriteLine("{0}.{1}", (int)value, value.ToString()); chucvu = (Position)int.Parse(Console.ReadLine()); Console.Write("Nhap so cong:"); songaycong = int.Parse(Console.ReadLine()); Console.Write("Nhap bac luong: "); bacluong = float.Parse(Console.ReadLine()); } public new float TinhLuong() { return ((2 * bacluong) / 26) * songaycong; //2 trieu VND } } //******************************** class NhanVienPTN : NhanVien { private float luongthang; public NhanVienPTN():base() { luongthang = 0; } public NhanVienPTN (String ht, int ns, Certificate bc, float lt):base(ht,ns,bc) { luongthang = lt; } public override string ToString() { return "[" + base.ToString() + "," + TinhLuong() + " trieu dong" + "]"; } public new void Nhap() { base.Nhap(); Console.Write("Nhap luong thang: "); luongthang = float.Parse(Console.ReadLine()); } public new float TinhLuong() { return luongthang; } } //******************************** class Program { static void Main(string[] args) { Console.WriteLine("Doi tuong NHAN VIEN:"); NhanVien nv = new NhanVien(); Console.WriteLine(nv); nv.Nhap(); Console.WriteLine(nv); Console.WriteLine(); Console.WriteLine("Doi tuong NHA KHOA HOC:"); NhaKhoaHoc nkh = new NhaKhoaHoc(); Console.WriteLine(nkh); nkh.Nhap(); Console.WriteLine(nkh); Console.WriteLine(); Console.WriteLine("Doi tuong NHA QUAN LY:"); NhaQuanLy nql = new NhaQuanLy(); Console.WriteLine(nql); nql.Nhap(); Console.WriteLine(nql); Console.WriteLine(); Console.WriteLine("Doi tuong NHAN VIEN PHONG THI NGHIEM:"); NhanVienPTN nvptn = new NhanVienPTN(); Console.WriteLine(nvptn); nvptn.Nhap(); Console.WriteLine(nvptn); Console.WriteLine(); Console.ReadKey(); } } }