自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

事例講述Visual Studio Employee類

開發(fā) 后端
這里介紹為Hourly Employee類添加一個(gè)Pay方法。Pay方法只有一個(gè)參數(shù),就是工作的小時(shí)數(shù)。在“類詳細(xì)信息”窗口,擴(kuò)展Pay方法的行來打開 “添加參數(shù)”項(xiàng),選擇“添加參數(shù)”行并輸入“Hours”作為參數(shù)名,修改類型為十進(jìn)制數(shù)。

學(xué)習(xí)Visual Studio時(shí),你可能會(huì)遇到Visual Studio Employee類問題,Visual Studio Employee類的派生類型必須具有計(jì)算薪水操作,這里將介紹Visual Studio Employee類問題的解決方法,在這里拿出來和大家分享一下。

#t#為Visual Studio Employee類添加一個(gè)CalculatePay抽象方法,該方法返回一個(gè)十進(jìn)制數(shù)。在Visual Studio Employee類的標(biāo)題打開其快捷菜單,選擇“添加”子菜單和“方法”菜單命令,為新方法命名為“CalculatePay”。在“類詳細(xì)信息”窗口設(shè)置十進(jìn)制數(shù)作為返回類型。該方法應(yīng)該設(shè)置為抽象的。打開CalculatePay方法的快捷菜單并修改“繼承修飾符”為abstract(抽象)。然后系統(tǒng)顯示一個(gè)消息框要求你對(duì)這一修改進(jìn)行確認(rèn),選“確定”。

Hourly Employee類應(yīng)該繼承Visual Studio Employee類。這一關(guān)系用繼承線來創(chuàng)建,具體做法是:將繼承線從Hourly Employee類拖到Visual Studio Employee類。

***,為Hourly Employee類添加一個(gè)Pay方法。Pay方法只有一個(gè)參數(shù),就是工作的小時(shí)數(shù)。在“類詳細(xì)信息”窗口,擴(kuò)展Pay方法的行來打開 “添加參數(shù)”項(xiàng),選擇“添加參數(shù)”行并輸入“Hours”作為參數(shù)名,修改類型為十進(jìn)制數(shù)。添加一個(gè)HourlyRate屬性到該類以使其完整,該屬性也是十進(jìn)制數(shù)類型的。

以下代碼由類關(guān)系圖創(chuàng)建。創(chuàng)建的函數(shù)是很粗略的,接下來只需要實(shí)現(xiàn)這些粗略的函數(shù)。

  1. public interface Iemployee  
  2. {  
  3. int Age  
  4. {  
  5. get;  
  6. set;  
  7. }  
  8. Name Fullname  
  9. {  
  10. get;  
  11. set;  
  12. }  
  13. string EmployeeInfo();  
  14. }  
  15. public struct Name  
  16. {  
  17. public string FirstName  
  18. {  
  19. get  
  20. {  
  21. throw new System.NotImplementedException();  
  22. }  
  23. set  
  24. {  
  25. }  
  26. }  
  27. public string LastName  
  28. {  
  29. get  
  30. {  
  31. throw new System.NotImplementedException();  
  32. }  
  33. set  
  34. {  
  35. }  
  36. }  
  37. }  
  38. public abstract class Employee : IEmployee  
  39. {  
  40. #region IEmployee Members  
  41. public int Age  
  42. {  
  43. get  
  44. {  
  45. throw new Exception(  
  46. "The method or operation is not implemented.");  
  47. }  
  48. set  
  49. {  
  50. throw new Exception(  
  51. "The method or operation is not implemented.");  
  52. }  
  53. }  
  54. public Name Fullname  
  55. {  
  56. get  
  57. {  
  58. throw new Exception(  
  59. "The method or operation is not implemented.");  
  60. }  
  61. set  
  62. {  
  63. throw new Exception(  
  64. "The method or operation is not implemented.");  
  65. }  
  66. }  
  67. public string EmployeeInfo()  
  68. {  
  69. throw new Exception(  
  70. "The method or operation is not implemented.");  
  71. }  
  72. #endregion  
  73. public abstract decimal CalculatePay();  
  74. }  
  75. public class HourlyEmployee : Employee  
  76. {  
  77. public decimal HourlyRate  
  78. {  
  79. get  
  80. {  
  81. throw new System.NotImplementedException();  
  82. }  
  83. set  
  84. {  
  85. }  
  86. }  
  87. public override decimal CalculatePay()  
  88. {  
  89. throw new Exception(  
  90. "The method or operation is not implemented.");  
  91. }  
  92. public void Pay(decimal Hours)  
  93. {  
  94. throw new System.NotImplementedException();  
  95. }  
責(zé)任編輯:佚名 來源: 51CTO.com
相關(guān)推薦

2009-11-10 15:12:21

Visual Stud

2009-11-05 14:03:28

Visual Stud

2009-12-11 13:14:45

Visual Stud

2009-12-03 18:38:57

Visual Stud

2009-12-16 16:57:03

Visual Stud

2009-12-02 15:44:00

Visual Stud

2009-11-06 13:54:09

Visual Stud

2009-11-06 13:25:35

Visual Stud

2009-11-06 11:04:29

Visual Stud

2009-11-06 11:16:17

Visual Stud

2009-11-11 12:55:52

Visual Stud

2009-11-09 10:08:31

Visual Stud

2009-11-09 17:04:20

Visual Stud

2009-11-06 14:42:24

Visual Stud

2013-11-14 01:09:35

微軟Visual StudVisual Stud

2023-09-05 07:32:22

vscode開源故障

2019-09-19 08:00:00

Visual StudVisual Stud編程語(yǔ)言

2009-12-02 09:43:38

Visual Stud

2024-02-27 12:42:38

開發(fā)前端

2010-03-11 15:23:44

Visual Stud
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)