Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace RegularExam
- {
- internal class Hat
- {
- private string type;
- private string color;
- private double price;
- public Hat(string type, string color, double price)
- {
- Type = type;
- Color = color;
- Price = price;
- }
- public string Type
- {
- get { return type; }
- set { type = value; }
- }
- public string Color
- {
- get { return color; }
- set { color = value; }
- }
- public double Price
- {
- get { return price; }
- set
- {
- if (value > 100)
- {
- throw new ArgumentException("Invalid hat price!");
- }
- price = value;
- }
- }
- public override string ToString()
- {
- return $"Hat {type} with color {color} costs {price:F2}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement