CodePudding user response:
CodePudding user response:
Build a class is half done, and then write a few judgment is all finished, do not give up advice, change careers,CodePudding user response:
Actually raised two,You can say what you want to do, and what problems encountered in the process, rather than throw your demand,
If you are still confused about! Here, you are advised to learn it!
CodePudding user response:
Public class lh-zd {Public int DJ;
Public int zk.
Public lh-zd (int DJ, int ZK) {
DJ=ZK DJ *;
Zk=zk;
}
Is such a meaning, roughly more than reading a book
CodePudding user response:
CodePudding user response:
This shouldn't be hard, I am also a small white, zero based work while learning c # 2 many monthsIn the blue tips I probably don't know if there is any need, but the code has a clue
CodePudding user response:
As the second floor says create a class to add a few finished it statementpublic class lh-zd
{
Double danjia=0;
Int shuliang=0;
Double zhekou=0;
Bool cuxiao=falsel
Int huiyuan=0;//0 for ordinary, 1 gold, 2 for platinum
Pubic int Shuliang
{
The get {return shuliang; }
The set {shuliang=value; }
}
}
If (cuxiao==false)
{if (huiyuan==0)
{jine=(double) shuliang * danjia}
Else if (huiyuan==1)
{jine=(double) danjia shuliang * * 0.9}
}
The else
{jine=(double) danjia shuliang * * 0.6}
Probably similar like this, I began to learn change programs use controls, the console program input and output is not too will write 0.0
CodePudding user response:
A bill for this design has a problem, name of commodity title didn't appear, whether the promotion is store control, also should not be controlled by the order, this book is not very good,Commodity type
Commodity number, name of commodity, unit price
Membership class
Member number, type
The shopping cart classes
Commodity, quantity
Shopping receipts class
Whether member, collection shopping, promotion, discount amount
Although do not conform to the requirements of the subject, may be more realistic, use vb.net wrote a, discuss together,
The Module MainModule
Sub Main ()
'definition shelf
Dim Storage As New List (Of the Product) From {
New Product With {, Id="P001," Name="coke", the Price=2.5 D},
The New Product With {, Id="P002," Name="rice", the Price=50}}
'define member
Dim member As New member With {, Id="Vip001," Name="zhang", the Type=member. MemberType. Platinum}
'get today whether promotion tag
Dim isDiscount As Boolean=False
'members into the shop and generate order
Dim bill As New bill (isDiscount, member, New List (Of Cart))
'shopping
Bill. The Carts. The Add (New Cart With {. Product=Storage (0), the Count=2})
Bill. The Carts. The Add (New Cart With {. Product=Storage (1), the Count=1})
Settlement
'For Each I In bill. The Carts
Console. WriteLine ($" commodity: {i.P. Roduct Name} : {i.C mount} ")
Next
Console. WriteLine ($" Member: {bill. Member. The Name} Discount: {bill. Discount} Amount: {bill. The Amount} ")
The Console. ReadKey ()
End Sub
End the Module
"' & lt; Summary>
"' commodity type
"' & lt;/summary>
Public Class Product
Public Property Id As String
Public Property Name As a String
Public Property Price As a Decimal
The End of the Class
"' & lt; Summary>
"' membership class
"' & lt;/summary>
Public Class Member
Public Property Id As String
Public Property Name As a String
Public Property Type As MemberType=MemberType. Standard
Public ReadOnly Property Discount As a Decimal
The Get
The Return Type/10 d
In the End Get
End Property
Public Enum MemberType
Standard=10
Gold=9
Platinum=8
End Enum
The End of the Class
"' & lt; Summary>
"' shopping cart class
"' & lt;/summary>
Public Class Cart
The Public Property of the Product As the Product
Public Property Count As Integer
The End of the Class
"' & lt; Summary>
"' shopping list
"' & lt;/summary>
Public Class Bill
Private isDiscount As Boolean
Public Sub New (isDiscount As a Boolean, member As member, carts As a List Of them (Cart))
Me. IsDiscount=isDiscount
Me. Member=Member
Me. The Carts=Carts
End Sub
Public Property Member As Member
Public ReadOnly Property Carts As New List (Of Cart)
Public ReadOnly Property Discount As a Decimal
The Get
If isDiscount Then
The Return of 0.6 D
The Else
Return Member. Discount
End the If
In the End Get
End Property
Public ReadOnly Property Amount As a Decimal
The Get
Return Carts. The Sum (Function (x) x.P roduct. Price * x.C mount) * Discount
In the End Get
End Property
The End of the Class
Commodity: coke quantity: 2
Commodity: rice quantity: 1
Member: zhang SAN discount: 0.8 amount: 44.00
CodePudding user response:
///& lt; Summary>
///cash charge
///& lt;/summary>
Public class CashSuper
{
Private double price;
Private int quantity;
Private double discount;
Private double total;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull