Breaking News
Loading...
Wednesday, August 22, 2012

Lớp thừa kế: Nhà quản lí, nhà khoa học, phòng thí nghiệm

8/22/2012 08:57:00 PM

Lass THONG TIN

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai28
{
    class 
THONGTIN
    
{
        protected 
string hotenbangcap,chucvu;
        protected 
int namsinh,ngaycong;
        protected 
float bacluong;
       public 
virtual void Nhap()
       {
           
Console.Write("Nhap ho ten: ");
            
hoten=Console.ReadLine();
            
Console.Write("Nhap bang cap: ");
           
bangcap=Console.ReadLine();
           
Console.Write("Nhap nam sinh: ");
           
namsinh int.Parse(Console.ReadLine());
             
Console.Write("Nhap chuc vu: ");
           
chucvu=Console.ReadLine();
             
Console.Write("Nhap ngay cong: ");
           
ngaycong=int.Parse(Console.ReadLine());
             
Console.Write("Nhap bac luong: ");
           
bacluong=float.Parse(Console.ReadLine());

       }
       public 
virtual void xuat()
       {
           
Console.WriteLine("Ho ten: "+hoten);
           
Console.WriteLine("Nam sinh: "+namsinh);
           
Console.WriteLine("Bang cap "+bangcap);
           
Console.WriteLine("Chuc vu: "+chucvu);
           
Console.WriteLine("Ngay cong "+ngaycong);
          
Console.WriteLine("Bac luong" +bacluong);
       }

    }
}  
class Cnhakhoahoc

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai28
{
    class 
Cnhakhoahoc:THONGTIN
    
{
        
float luong;
         
int sobaidang;
        public 
override void Nhap()
        {
            
base.Nhap();
            
Console.Write("so bai dang da cong bo: ");
            
sobaidang=int.Parse(Console.ReadLine());

        }
        public 
override void xuat()
        {
            
base.xuat();
            
Console.WriteLine(sobaidang);
            
luong ngaycong bacluong;
            
Console.WriteLine("Luong :" luong);
        }

        public 
void NhapDS(Cnhakhoahoc []a,int n)
        {
            for(
int i=0;i<n;i++)
                {
                
Console.WriteLine("Nhap thong tin nha khoa hoc thu {0}",i+1);
                
a[i]=new Cnhakhoahoc();
                
a[i].Nhap();
            
                }
           }

        public 
void XuatDS(Cnhakhoahoc[] aint n)
        {
            
float tong 0;
            for (
int i 0ni++)
            {
                
Console.WriteLine("Thong tin nha khoa hoc thu {0}"1);
                
a[i].xuat();
                
tong += a[i].luong;
            }
            
Console.WriteLine("Tong luong chi tra" tong);
        }

    }
}  

class Cnhaquanli

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai28
{
    class 
Cnhaquanli:THONGTIN
    
{
        
float luong;
        public new 
void Nhap()
        {
            
base.Nhap();
        }
        public new 
void xuat()
        {
            
base.xuat();
            
luong ngaycong bacluong;
            
Console.WriteLine("Luong :" luong);
        }
        public 
void NhapDS(Cnhaquanli[] aint n)
        {
            for (
int i 0ni++)
            {
                
Console.WriteLine("Nhap thong tin nha quan li thu {0}"1);
                
a[i] = new Cnhaquanli();
                
a[i].Nhap();

            }
        }
        public 
void XuatDS(Cnhaquanli[] aint n)
        {
            
float tong 0;
            for (
int i 0ni++)
            {
                
Console.WriteLine("Thong tin nha nha quan li thu {0}"1);
                
a[i].xuat();
                
tong += a[i].luong;
            }
            
Console.WriteLine("Tong luong chi tra" tong);
        }
    }
}  

class Cphongthinghiem

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai28
{
    class 
Cphongthinghiem:THONGTIN
    
{
        
int luongtrongthang;
        public 
override void Nhap()
        {
            
//base.Nhap();
        
            
Console.Write("Nhap ho ten: ");
            
hoten Console.ReadLine();
            
Console.Write("Nhap bang cap: ");
            
bangcap Console.ReadLine();
            
Console.Write("Nhap nam sinh: ");
            
namsinh int.Parse(Console.ReadLine());
            
Console.Write("Luong trong thang ");
            
luongtrongthang int.Parse(Console.ReadLine());
         
       
        }
        public 
override void xuat()
        {
            
//base.xuat();
            
Console.WriteLine("Ho ten "+hoten);
            
Console.WriteLine("Nam sinh "+namsinh);
            
Console.WriteLine("Bang cap "+bangcap);
            
Console.WriteLine("Luong trong thang "luongtrongthang);
        }

        public 
void NhapDS(Cphongthinghiem[] aint n)
        {
            for (
int i 0ni++)
            {
                
Console.WriteLine("Nhap thong tin nhan vien phong thi nghiem thu {0}"1);
                
a[i] = new Cphongthinghiem();
                
a[i].Nhap();

            }
        }

        public 
void XuatDSCphongthinghiem[] aint n)
        {
        
            
float tong 0;
            for (
int i 0ni++)
            {
                
Console.WriteLine("Thong tin nhan vien phong thi nghiem thu {0}"1);
                
a[i].xuat();
                
tong += a[i].luongtrongthang;
            }
            
Console.WriteLine("Tong luong chi tra" tong);
        }
    }
}  

class program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai28
{
    class 
Program
    
{
        static 
void Main(string[] args)
        {
            
int n,m,p;
            
Cnhakhoahoc []a1 = new Cnhakhoahoc [100];
            
Cnhakhoahoc a = new Cnhakhoahoc();
            
Cnhaquanli[] b1 = new Cnhaquanli[100];
            
Cnhaquanli b = new Cnhaquanli();
            
Cphongthinghiem[] c1= new Cphongthinghiem[100];
            
Cphongthinghiem c = new Cphongthinghiem();
            
Console.Write("nhap so luong nha khoa hoc: ");
            
int.Parse(Console.ReadLine());
            
a.NhapDS(a1n);
            
Console.Write("nhap so luong nha quan li: ");
            
int.Parse(Console.ReadLine());
            
b.NhapDS(b1,m);
            
Console.Write("nhap so luong nhan vien phong thi nghiem: ");
            
int.Parse(Console.ReadLine());
            
c.NhapDS(c1p);
            
a.XuatDS(a1n);
            
b.XuatDS(b1m);
            
c.XuatDS(c1,p);
        }
         
    }
}  


1 comments:

 
Toggle Footer