Home > Net >  The small white to overcome
The small white to overcome

Time:10-03

CodePudding user response:

 
Public class bill
{
Public class billModel
{
Private decimal _price;
Private decimal _number;
Private decimal _discount;
Private decimal _account;
Private DateTime _date;
Private bool _isPromotion;
Private int _memberType;

///& lt; Summary>
///unit price
///& lt;/summary>
Public decimal price
{
The get {return _price; }
The set {_price=value; }
}
///& lt; Summary>
///quantity
///& lt;/summary>
The public a decimal number
{
The get {return _number; }
The set {_number=value; }
}
///& lt; Summary>
///discount
///& lt;/summary>
Public decimal discount
{
The get {return _discount; }
The set {_discount=value; }
}
///& lt; Summary>
///amount
///& lt;/summary>
Public decimal account
{
The get {return _account; }
The set {_account=value; }
}
///& lt; Summary>
///occurrence date
///& lt;/summary>
Public DateTime date
{
The get {return _date; }
The set {_date=value; }
}
///& lt; Summary>
///whether discount
///& lt;/summary>
Public bool isPromotion
{
The get {return _isPromotion; }
The set {_isPromotion=value; }
}
///& lt; Summary>
///member types: 0 regular members, member of 1 gold, 2 platinum
///& lt;/summary>
Public int memberType
{
The get {return _memberType; }
The set {_memberType=value; }
}

}

Public billModel GetAccount (decimal goodsPrice, decimal goodsNumber, int membertype, DateTime mydata)
{
BillModel rs=new billModel ();
Rs. Price=goodsPrice;
Rs. Number=goodsNumber;
Rs. MemberType=memberType;
Rs. The date=mydata;
The switch (membertype)
{
Case 0:
Rs. IsPromotion=false;
Rs. Discount=1;
break;
Case 1:
Rs. IsPromotion=true;
Rs. Discount=0.9 M;
break;
Case 2:
Rs. IsPromotion=true;
Rs. Discount=0.8 M;
break;
}
Rs. Account=rs. Price * rs. Number * rs. Discount;
Return the rs;
}
}

CodePudding user response:

It's a good comrade upstairs!
Explain very well

CodePudding user response:

Write in word order;

First divided into marketing or promotion not two cases (if promotion else don't promotion) : promotion, if the commodity 6 fold; If not sales, judge by enumeration member type, give a response member discount;

CodePudding user response:

Borrow a code change the # 1 floor, I feel should be more in line with coding standards and proposals:
 
Public class BillModel
{
///& lt; Summary>
///unit price
///& lt;/summary>
Public decimal Price {get; The set; }
///& lt; Summary>
///quantity
///& lt;/summary>
Public decimal Count {get; The set; }

///& lt; Summary>
///discount
///& lt;/summary>
Public decimal Discount
{
The get
{
If (IsPromotion)
The return of 0.6 M;

The switch (MemberType)
{
Case VIPType. Golden:
The return of 0.9 M;
Case VIPType. Platinum:
The return of 0.8 M;
Default:
The return of 1.0 M;
}
}
}

///& lt; Summary>
///amount
///& lt;/summary>
Public decimal Account
{
The get
{
Return the Discount Price * * Count;
}

}
///& lt; Summary>
///occurrence date
///& lt;/summary>
Public DateTime Date {get; The set; }

///& lt; Summary>
///whether discount
///& lt;/summary>
Public bool IsPromotion {get; The set; }

///& lt; Summary>
///member types: 0 regular members, member of 1 gold, 2 platinum
///& lt;/summary>
Public VIPType MemberType {get; The set; }
}

Public enum VIPType
{
Normal=0,
Golden=1,
Platinum=2,
}

CodePudding user response:

 
reference Amon, 4/f, Amon response:
borrow # 1/f, changed the code, I feel should be more in line with coding standards and proposals:
[code=csharp]
Public class BillModel
{
///& lt; Summary>
///unit price
///& lt;/summary>
Public decimal Price {get; The set; }
///& lt; Summary>
///quantity
///& lt;/summary>
Public decimal Count {get; The set; }

///& lt; Summary>
///discount
///& lt;/summary>
Public decimal Discount
{
The get
{
If (IsPromotion)
The return of 0.6 M;

The switch (MemberType)
{
Case VIPType. Golden:
The return of 0.9 M;
Case VIPType. Platinum:
The return of 0.8 M;
Default:
The return of 1.0 M;
}
}
}

///& lt; Summary>
///amount
///& lt;/summary>
Public decimal Account
{
The get
{
Return the Discount Price * * Count;
}

}
///& lt; Summary>
///occurrence date
///& lt;/summary>
Public DateTime Date {get; The set; }

///& lt; Summary>
///whether discount
///& lt;/summary>
Public bool IsPromotion {get; The set; }

///& lt; Summary>
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related