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 Perfume
- {
- private string brand;
- private double price;
- public Perfume (string brand, double price)
- {
- Brand = brand;
- Price = price;
- }
- public string Brand
- {
- get { return brand; }
- set { brand = value; }
- }
- public double Price
- {
- get { return price; }
- set
- {
- if (value > 100)
- {
- throw new ArgumentException("Invalid perfume price!");
- }
- price = value;
- }
- }
- public override string ToString()
- {
- return $"Perfume {brand} costs {price:F2}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement