Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ShoppingSpree
- {
- public class Product
- {
- private string name;
- private double cost;
- public Product(string name, double cost)
- {
- this.Name = name;
- this.Cost = cost;
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- name = value;
- }
- }
- public double Cost
- {
- get
- {
- return cost;
- }
- set
- {
- if (value < 0)
- {
- throw new Exception("Money cannot be negative");
- }
- this.cost = value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement