Hãy sá»­ dụng tối Ä‘a chức năng Search, trước khi đặt câu há»i
 


Gá»­i Ãá» Tài Má»›i Trả lá»i
  #11 (permalink)  
Old 11-03-2010, 12:38 AM
Perfect_Love's Avatar
Cá nhân
Thực tập sinh
Thành viên thứ: 416
Tham gia: Oct 2008
Bài viết: 3
   
Thông Tin
Tên Thật: Nguyá»…n Văn Tuyá»n
Äến từ: Hà Ná»™i
Giới tính:
Äiện thoại: 0972848208
Cám ơn: 1
Thanked 1 Time in 1 Post
Default

Hì mình vừa nghịch code bài này hjz Có gì sai má»i ngưá»i chỉ giáo nha.
Lá»›p Employees
using System;
using System.Collections.Generic;
using System.Text;

namespace Example
{
    class 
Employees
    
{
        
int empID;
        
String empName;
        
String department;
        
int numWork;

        public 
Employees(){
            
empID 10;
            
empName "Nguyen Van Tuyen";
            
department "Aptech";
            
numWork 0;
        }

        public 
Employees(int empIDString empNameString departmentint numWork) {
            
this.empID empID;
            
this.empName empName;
            
this.department department;
            
this.numWork numWork;
        }
     
        public 
int _empID {
            
set empID value; }
            
get { return empID; }
        }

        public 
String _empName
        
{
            
set empName value; }
            
get { return empName; }
        }

        public 
String _department
        
{
            
set department value; }
            
get { return department; }
        }

        public 
int _numWork
        
{
            
set numWork value; }
            
get { return numWork; }
        }

        public 
void Input() {
            
nhap_id:
            try
            {
                
Console.Write("Input empID: ");
                
empID Convert.ToInt32(Console.ReadLine());
            }
            catch (
Exception) {
                
Console.WriteLine("Loi: Phai nhap vao mot so nguyen!");
                
goto nhap_id;
            }            
                
Console.Write("Input empName: ");
                
empName Console.ReadLine();            
            
Console.Write("Input department: ");
            
department Console.ReadLine();

            
input_numwork:
            try
            {
                
Console.Write("Input numWork: ");
                
numWork Convert.ToInt32(Console.ReadLine());
            }
            catch (
Exception) {
                
Console.WriteLine("Loi: Phai nhap vao mot so nguyen!");
                
goto input_numwork;
            }
        }

        public 
virtual void DisplayDetail() {            
            
Console.WriteLine("empName: {0}",empName);            
            
Console.WriteLine("department: {0}",department);            
            
Console.WriteLine("numWork: {0}",numWork);
        }
    }

Lá»›p: TemporaryEmp
using System;
using System.Collections.Generic;
using System.Text;

namespace Example
{
    class 
TemporaryEmpEmployees
    
{
        
int workDay;

        public 
TemporaryEmp():base()  {
            
workDay 0;
        }
        public 
void input_workDay() {
            try
            {
                
Console.WriteLine("Input workDay: ");
                
workDay Convert.ToInt16(Console.ReadLine());
            }
            catch (
Exception) {
                
Console.WriteLine("Loi: Phai nhap vao so nguyen!");
                
input_workDay();
            }
        }
        public 
int CalculateSalary() {
            
int Salary;            
            if (
workDay <= 25)
            {
                
Salary workDay 50000;
            }
            else
            {
                
Salary 25 50000 + (workDay 25) * 50000 2;
            }
            return 
Salary;
        }
        public 
override void DisplayDetail() {
            
base.DisplayDetail();
            
Console.WriteLine("Salary: {0}",CalculateSalary());
        }
    }

Lá»›p: EmployeeManagement
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace Example
{
    class 
EmployeeManagement
    
{
        
TemporaryEmp[] list_emp = new TemporaryEmp[100];                
        
int n;

        public 
void inputEmployee() {
            
Console.Write("Input number of employees now: ");
            
Convert.ToInt32(Console.ReadLine());
            for (
int i 0ni++)
            {
                
list_emp[i] = new TemporaryEmp();
            
nhap_lai:
                
list_emp[i].Input();
                for (
int j 0ij++) {
                    if (
list_emp[i]._empID == list_emp[j]._empID) {
                        
Console.WriteLine("Nhan vien ban nhap da co.Moi ban nhap lai!");
                        
goto nhap_lai;
                    }
                }
                    
list_emp[i].input_workDay();
                
Console.WriteLine("--------------------------------");
            }
        }
        public 
void display_array_Emp() {
            for (
int i 0ni++)
            {
                
list_emp[i].DisplayDetail();
                
Console.WriteLine("--------------------------------");
            }
        }

        public 
void display_maxNum() {
            
TemporaryEmp maxYear = new TemporaryEmp();
            
maxYear list_emp[0];

            for (
int i 1ni++) {
                if (
maxYear._numWork list_emp[i]._numWork) {
                    
maxYear list_emp[i];
                }
            }
            
maxYear.DisplayDetail();
        }
    }

Lá»›p: Test
using System;
using System.Collections.Generic;
using System.Text;

namespace Example
{
    class 
Test
    
{
        
EmployeeManagement empMng = new EmployeeManagement();
        
void menu() {
            
int choose;
            do
            {
                
Console.WriteLine("press 1 to enter Array Employee");
                
Console.WriteLine("press 2 to display array of Employee");
                
Console.WriteLine("press 3 to display array of Employee has max number of years working.");
                
Console.WriteLine("press 4 to exit");
                
Console.WriteLine("Input: ");
                
choose Convert.ToInt16(Console.ReadLine());
                switch (
choose)
                {
                    case 
1:
                        
Console.WriteLine("Nhap mang nhan vien!");
                        
empMng.inputEmployee();
                        break;
                    case 
2:
                        
Console.WriteLine("Hien thi mang nhan vien!");
                        
empMng.display_array_Emp();
                        break;
                    case 
3:
                        
Console.WriteLine("Hien thi nhan vien co so nam kinh nghiem nhieu nhat!");
                        
empMng.display_maxNum();
                        break;
                    case 
4:
                        
Console.WriteLine("Exit the program!");
                        break;
                    default:
                        
Console.WriteLine("Input fail!");
                        break;
                }
                
Console.ReadKey();
                
Console.Clear();
            } while (
choose != 4);
        }
        static 
void Main(string[] args)
        {
            
Test t = new Test();
            
t.menu();

        }
    }


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19977]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by Perfect_Love[/url][/size][/right]
 
Chữ ký

Welcome to Bachkhoa-Aptech Online Community. We hope Perfect_Love find much more useful information from our forum. Join us to share our IT interest !!!


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19977]Copyright © Diá»…n Äàn BachKhoa-Aptech - Perfect_Love's Signature[/url][/size][/right]
 

Thay đổi nội dung bởi: Perfect_Love, 11-03-2010 lúc 09:23 AM.
Trả Lá»i Vá»›i Trích Dẫn
Thành viên đã cảm ơn Perfect_Love vỠbài viết này:
dovuhuong (26-05-2010)
  #12 (permalink)  
Old 11-03-2010, 12:40 AM
Perfect_Love's Avatar
Cá nhân
Thực tập sinh
Thành viên thứ: 416
Tham gia: Oct 2008
Bài viết: 3
   
Thông Tin
Tên Thật: Nguyá»…n Văn Tuyá»n
Äến từ: Hà Ná»™i
Giới tính:
Äiện thoại: 0972848208
Cám ơn: 1
Thanked 1 Time in 1 Post
Default

Hjx đặt trong thẻ code mà nó bị sao ko biết. Mod sửa zùm cái nha ^^.
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19978]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by Perfect_Love[/url][/size][/right]
 
Chữ ký

Welcome to Bachkhoa-Aptech Online Community. We hope Perfect_Love find much more useful information from our forum. Join us to share our IT interest !!!


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19978]Copyright © Diá»…n Äàn BachKhoa-Aptech - Perfect_Love's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
  #13 (permalink)  
Old 27-07-2010, 11:12 AM
boyzozanh's Avatar
Cá nhân
Há»c viên má»›i
Thành viên thứ: 27325
Tham gia: Apr 2010
Bài viết: 14
   
Thông Tin
Tên Thật: zozanh
Äến từ: zozanh
Giới tính:
Cám ơn: 0
ÄÆ°á»£c cám Æ¡n 0 lần trong 0 bài viết
Default

thật là đáng tiếc !!! nếu không tự mình làm thì sau này đi làm thì sao có thể....
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=26500]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by boyzozanh[/url][/size][/right]
 
Chữ ký
Sá»NG CHẾT MẶC BAY@};
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=26500]Copyright © Diá»…n Äàn BachKhoa-Aptech - boyzozanh's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
Trả lá»i


Ãang Ä‘á»c: 1 (0 thành viên và 1 khách)
 
Ãiá»u Chỉnh
Xếp Bài

Quyá»n Sá»­ Dụng Ở Diá»…n Ãàn
Bạn không thể Gửi bài mới
Bạn không thể Gá»­i trả lá»i
Bạn không thể Gửi File đính kèm
Bạn không thể sửa bài viết của mình

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt
Trackbacks are Mở
Pingbacks are Mở
Refbacks are Mở



Liên Lạc - Trang Chủ - Lưu Trữ - Trở Lên Trên