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

📄 pieceworker.cs

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

namespace Employees
{
   public class PieceWorker : Employee 
   {
      private decimal wagePerPiece; // wage per piece produced
      private int quantity;         // quantity of pieces produced

      // constructor
      public PieceWorker( string firstNameValue, 
         string lastNameValue, decimal wagePerPieceValue, 
         int quantityValue )
         : base( firstNameValue, lastNameValue )
      {
         WagePerPiece = wagePerPieceValue;
         Quantity = quantityValue;
      }

      // property WagePerPiece
      public decimal WagePerPiece
      {
         get
         {
            return wagePerPiece;
         }

         set
         {
            if ( value > 0 )
               wagePerPiece = value;
         }
      }

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

         set
         {
            if ( value > 0 )
               quantity = value;
         }
      }

      // override base-class method to calculate 
      // PieceWorker's earnings
      public override decimal Earnings()
      {
         return Quantity * WagePerPiece;
      }

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

⌨️ 快捷键说明

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