Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace class1
- {
- public class Keyboard
- {
- public string Brand { get; set; }
- private int keyCount;
- public int KeyCount
- {
- get
- {
- return keyCount;
- }
- set
- {
- if (value < 80 || value > 130)
- {
- throw new ArgumentException("Invalid keys number");
- }
- keyCount = value;
- }
- }
- public string KbdType { get; set; }
- public double Price { get; set; }
- public Keyboard(string brand, string kbdType, int keyCount, double price)
- {
- this.Brand = brand;
- this.KbdType = kbdType;
- this.KeyCount = keyCount;
- this.Price = price;
- }
- public override string ToString()
- {
- return string.Format("KBD {0}, {1}, {2} keys, Price: {3:f2}]",
- Brand, KbdType, KeyCount, Price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement