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

Time:10-03

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

And is a demand, let others to do for you free of charge, and the brain to knead

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

 
Public class Billcs
{
Double _price;
Int _number;
Double _discount;
Double _mouney;
DateTime _date;
Bool _isPromotion;

///& lt; Summary>
///unit price
///& lt;/summary>
Public double Price {get=& gt; _price; The set=& gt; _price=value; }
///& lt; Summary>
///quantity
///& lt;/summary>
Public int Number {get=& gt; _number; The set=& gt; _number=value; }
///& lt; Summary>
///discount
///& lt;/summary>
Public double Discount {get=& gt; _discount; }
///& lt; Summary>
///amount
///& lt;/summary>
Public double Mouney {get=& gt; Price * Number * Discount; }
///& lt; Summary>
///date
///& lt;/summary>
Public DateTime Date {get=& gt; _date; The set=& gt; _date=value; }
///& lt; Summary>
///whether the promotion
///& lt;/summary>
Public bool IsPromotion {get=& gt; _isPromotion; The set=& gt; _isPromotion=value; }
///& lt; Summary>
///member type
///& lt;/summary>
Enum _vipType
{
///& lt; Summary>
///ordinary
///& lt;/summary>
Ordinary=1,
///& lt; Summary>
Gold///
///& lt;/summary>
Gold=2,
///& lt; Summary>
///platinum
///& lt;/summary>
Platinum=3
}


}

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

Give it up, it's too difficult

CodePudding user response:

Another post back,

A top after a class definition of each attribute, more members, directly calculate the value of the attributes of other,

Set the set the get 2 indexer permissions,

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:
 
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,
}


Can, and the best encapsulation attribute permissions, good design,
  •  Tags:  
  • C#
  • Related