Home » Source Code » Employee code

Employee code

irinvl
2017-04-07 10:51:17
The author
View(s):
Download(s): 0
Point (s): 1 
Category Category:
c#c# AllAll

Description

using System;

4

5 public class CommissionEmployee : object

6{ 7

page452image8296 page452image8456 page452image8616 page452image8776 page452image8936

8

private string firstName;

page452image10072 page452image10232 page452image10392

private string lastName;

page452image11080 page452image11240 page452image11400 page452image11560 page452image11720

9

private string socialSecurityNumber;

page452image12856 page452image13016 page452image13176 page452image13336 page452image13496

10

private decimal grossSales; // gross weekly sales

page452image14792 page452image14952 page452image15112 page452image15272 page452image15432

11

private decimal commissionRate; // commission percentage

page452image16688

12
13 // five-parameter constructor

page452image17720 page452image17880 page452image18040 page452image18200

14

public CommissionEmployee( string first, string last, string ssn,

page452image19536 page452image19696 page452image19856 page452image20016 page452image20176

15

decimal sales, decimal rate )

page452image21392 page452image21552 page452image21712 page452image21872 page452image22032

16 17

{

page452image23232 page452image23392 page452image23552 page452image23712
// implicit call to object constructor occurs here 
page452image24600 page452image24760 page452image24920 page452image25080 page452image25240

18

firstName = first; 
page452image26376 page452image26536 page452image26696 page452image26856 page452image27016

19

lastName = last; 
page452image28152 page452image28312 page452image28472 page452image28632 page452image28792

20

socialSecurityNumber = ssn; 
page452image29928 page452image30088 page452image30248 page452image30408 page452image30568

21 22

GrossSales = sales; // validate gross sales via property 
page452image32088 page452image32248 page452image32408 page452image32568
CommissionRate = rate; // validate commission rate via property 
page452image33496 page452image33656 page452image33816 page452image33976 page452image34136

23

} // end five-parameter CommissionEmployee constructor

page452image35392

24

25 // read-only property that gets commission employee's first name

26 public string FirstName 27 {

28 get

29 {

30 return firstName; 31 } // end get

32 } // end property FirstName

33

34 // read-only property that gets commission employee's last name

35 public string LastName 36 {

37 get

38 {

39 return lastName;

40 } // end get
41 } // end property LastName

42

43 // read-only property that gets

44 // commission employee's social security number

45 public string SocialSecurityNumber 46 {

47 get

48 {
49 return socialSecurityNumber;

Fig. 11.4 | CommissionEmployee class represents a commission employee. (Part 1 of 2.)

412 Chapter 11 Object-Oriented Programming: Inheritance

50 } // end get

51 } // end property SocialSecurityNumber

52
53 // property that gets and sets commission employee's gross sales

54 public decimal GrossSales

55 {

56 get

57 {

58 return grossSales; 59 } // end get

60 set

61 {

62 if ( value >= 0 )
63 grossSales = value;

64 else

65 throw new ArgumentOutOfRangeException(

66 "GrossSales", value, "GrossSales must be >= 0" );

67 } // end set
68 } // end property GrossSales

69

70 // property that gets and sets commission employee's commission rate

71 public decimal CommissionRate

72 {
73 get

74 {

75 return commissionRate;

  1. 76  } // end get

  2. 77  set

78 {

79 if ( value > 0 && value < 1 )

80 commissionRate = value;

81 else
82 throw new ArgumentOutOfRangeException( "CommissionRate",

83 value, "CommissionRate must be > 0 and < 1" );

84 } // end set

85 } // end property CommissionRate

86 87

page453image27016 page453image27176
// calculate commission employee's pay 
page453image28544 page453image28704 page453image28864 page453image29024

88

public decimal Earnings()

page453image30160 page453image30320 page453image30480 page453image30640 page453image30800

89

{

page453image31856 page453image32016 page453image32776

90 91

return commissionRate * grossSales;

page453image34096 page453image34256 page453image34416

92

} // end method Earnings 
page453image36224 page453image36384 page453image36544 page453image36704

93

// return string representation of CommissionEmployee object

page453image38000 page453image38160 page453image38320 page453image38480 page453image38640

94

public override string ToString()

page453image39816 page453image39976 page453image40136 page453image40296 page453image40456

95 96

{

page453image41656 page453image41816 page453image41976 page453image42136

return string.Format(

page453image42784 page453image42944 page453image43104 page453image43264 page453image43424

97

"{0}: {1} {2}\n{3}: {4}\n{5}: {6:C}\n{7}: {8:F2}",

page453image44680 page453image44840 page453image45000 page453image45160 page453image45320

98

"commission employee", FirstName, LastName,

page453image46496 page453image46656 page453image46816 page453image46976 page453image47136

99

"social security number", SocialSecurityNumber,

page453image48312 page453image48472 page453image48632 page453image48792

100
101
102 } // end class CommissionEmployee 

Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
emp.cs2.88 kB2017-04-07 10:47
...
Sponsored links

Comments

(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words
  • 1
  • Page 1
  • Total 1

Employee code (1.19 kB)

Need 1 Point(s)
Your Point (s)

Your Point isn't enough.

Get 22 Point immediately by PayPal

Point will be added to your account automatically after the transaction.

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more Points

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D