Book.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace BooksManageSystem
  5. {
  6. public class Book
  7. {
  8. private int _bookID;
  9. public int BookID
  10. {
  11. get { return _bookID; }
  12. set { _bookID = value; }
  13. }
  14. private string _bookName;
  15. public string BookName
  16. {
  17. get { return _bookName; }
  18. set { _bookName = value; }
  19. }
  20. private double _price;
  21. public double Price
  22. {
  23. get { return _price; }
  24. set { _price = value; }
  25. }
  26. private double _orderPrice;
  27. public double OrderPrice
  28. {
  29. get { return _orderPrice; }
  30. set { _orderPrice = value; }
  31. }
  32. private int _count;
  33. public int Count
  34. {
  35. get { return _count; }
  36. set
  37. {
  38. if (value < 0)
  39. {
  40. throw new ArgumentException("书籍的数量不能为负数");
  41. }
  42. else
  43. {
  44. _count = value;
  45. }
  46. }
  47. }
  48. private bool _isStudentBook;
  49. /// <summary>
  50. /// 是否是学生用书
  51. /// </summary>
  52. public bool IsStuBook
  53. {
  54. get { return _isStudentBook; }
  55. set { _isStudentBook = value; }
  56. }
  57. public Book(int id,string name,double price,double orderprice,int count,bool stuBook)
  58. {
  59. this._bookID = id;
  60. this._bookName = name;
  61. this._price = price;
  62. this._orderPrice = orderprice;
  63. this._count = count;
  64. this._isStudentBook = stuBook;
  65. }
  66. public override string ToString()
  67. {
  68. return this.BookID + "\t" + this.BookName + "\t" + this.Price + "\t" + this.OrderPrice + "\t" + this.Count + "\t" + this.IsStuBook;
  69. }
  70. }
  71. }