pieceworker.cs
来自「C#语言高级编成,我多年总结的经验,肯定能让你学到很多」· CS 代码 · 共 67 行
CS
67 行
// Fig. 7.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 + =
减小字号Ctrl + -
显示快捷键?