⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commissionworker.cs

📁 this is a good book for the visual c#
💻 CS
字号:
// Fig. 10.11: CommissionWorker.cs
// CommissionWorker class derived from Employee
using System;

namespace Employees
{  
   public class CommissionWorker : Employee
   {
      private decimal salary;     // base weekly salary
      private decimal commission; // amount paid per item sold
      private int quantity;       // total items sold

      // constructor
      public CommissionWorker( string firstNameValue,
         string lastNameValue, decimal salaryValue,
         decimal commissionValue, int quantityValue ) 
         : base( firstNameValue, lastNameValue )
      {
         WeeklySalary = salaryValue;
         Commission = commissionValue;
         Quantity = quantityValue;
      }

      // property WeeklySalary
      public decimal WeeklySalary
      {
         get
         {
            return salary;
         }

         set
         {
            // ensure non-negative salary value
            if ( value > 0 )
               salary = value;
         }
      }

      // property Commission
      public decimal Commission
      {
         get
         {
            return commission;
         }

         set
         {
            // ensure non-negative commission value
            if ( value > 0 )
               commission = value;
         }
      }

      // property Quantity
      public int Quantity
      {
         get
         {
            return quantity;
         }

         set
         {
            // ensure non-negative quantity value
            if ( value > 0 )
               quantity = value;
         }
      }

      // override base-class method to calculate 
      // CommissionWorker's earnings
      public override decimal Earnings()
      {
         return WeeklySalary + Commission * Quantity;
      }

      // return string representation of CommissionWorker
      public override string ToString()
      {
         return "CommissionWorker: " + base.ToString();
      }

   } // end class CommissionWorker
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -