Home > Net >  Not overloaded methods and questions of this class, for a great god a wave analysis
Not overloaded methods and questions of this class, for a great god a wave analysis

Time:09-27

A, commodity type
1, define the commodity type (number, name, production date, shelf-life, price), method (the introduction of goods, sales)
1) all member fields must be encapsulated as attributes, the production date should be in the day before, the price should be greater than zero, the shelf life should be greater than 0 day,
2) define at least two constructors, used for object instantiated,
3) the commodity description method does not need arguments and return values; Commodity sales method returns the actual sales price; This approach requires overloading, no method according to the commodity price sale, a method of parameters for a discount discount rate, commodity actual sale price and the price and discount rate calculation is as follows:
(1) merchandise sales date will be on the same day
(2) the goods sales, if the shelf life is over 30%, then the discount sales; Shelf life is over 50%, according to 7.5 fold sales; Shelf life is over 80%, according to the 5 fold sales; Shelf life is over 90%, then press 2 fold sales; Shelf life is over, by throwing an exception "overdue goods, may not sell, must be destroyed!" ,
2, the commodity type application
1) in the main method to instantiate multiple (3 or more) goods, printing product sales price and discount rate, the multiple

CodePudding user response:

This is your homework,

CodePudding user response:

reference 1st floor is nu month god reply:
, this is your homework

Yes, sales method to calculate the discount there can't be

CodePudding user response:

refer to the second floor Bai Dongcheng response:
Quote: refer to 1st floor is nu month god reply:
, this is your homework

Yes, sales method to calculate the discount there can't be

This is typical of the strategy pattern,

CodePudding user response:

The
refer to the original poster Bai Dongcheng response:
, a commodity type
1, define the commodity type (number, name, production date, shelf-life, price), method (the introduction of goods, sales)
1) all member fields must be encapsulated as attributes, the production date should be in the day before, the price should be greater than zero, the shelf life should be greater than 0 day,
2) define at least two constructors, used for object instantiated,
3) the commodity description method does not need arguments and return values; Commodity sales method returns the actual sales price; This approach requires overloading, no method according to the commodity price sale, a method of parameters for a discount discount rate, commodity actual sale price and the price and discount rate calculation is as follows:
(1) merchandise sales date will be on the same day
(2) the goods sales, if the shelf life is over 30%, then the discount sales; Shelf life is over 50%, according to 7.5 fold sales; Shelf life is over 80%, according to the 5 fold sales; Shelf life is over 90%, then press 2 fold sales; Shelf life is over, by throwing an exception "overdue goods, may not sell, must be destroyed!" ,
2, the commodity type application
1) in the main method to instantiate multiple (3 or more) goods, print out the product sales price and discount rate, multiple
big design pattern, the book cashier system chapter related code, a simple design pattern, and also the strategy pattern
  •  Tags:  
  • C#
  • Related