Advertisement
khaiwen1111

practical 3 part b question 5

Jun 28th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. Class item
  2. {
  3. private decimal unitPrice;
  4. private int quantity;
  5.  
  6. public int Quantity
  7. {
  8. get{return quantity;}
  9. set{quantity= value;}
  10. }
  11.  
  12. public decimal CalculateCost()
  13. {
  14. return unitPrice*quantity
  15. }
  16. }
  17.  
  18. class test{
  19. //mainmethod
  20. Item item = new item();
  21. item.Quantity = 5;
  22. item.UnitPrice = 12.50;
  23. item.CalculateCost(); //display the cost
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement