作者matrixjimmy (Jimmy)
看板NTUBIME-99
標題[學業] C++習題翻譯..
時間Sat Oct 14 21:24:41 2006
這是翻譯文,稍後會再PO如何解題...
3.15 (Date Class)Create a class called Date that includes three pieces of
information as data members - a month (type int), a day (type int) and a
year (type int). Your class should have a constructor with three parameters
that uses the parameters to initialize the three data members. For the
purpose of this exercise, assume that the values provided for the year and
day are correct, but ensure that the month value is in the range 1-12; if
it is not, set the month to 1. Provide a set and a get function for each
data member. Provide a member function displayDate that displays the month,
day and year separated by forward slashes(/). Write a test program that
demonstrates class Date's capabilities.
建立一個名叫"Date"的資料類別(Class)。內容包含三個成員變數:
1.一個整數型態的變數叫"month"
2.一個整數型態的變數叫"day"
3.一個整數型態的變數叫"year"
這個Class必須包含三個啟動成員變數的敘述(建構子 constructor),
這個題目的所要達成的目標就是
假設輸入年、月、日,而其中月的範圍是在1~12之間。
若年與日正確但月份錯誤,則將月份設為1。
這個Class也要為成員變數提供一個成員函式(function)叫"displayDate"
displayDate 要可以以這種格式顯示年/月/日
寫一個程式來驗證你的資料類別是否正確。
--
燃燒吧,我的小宇宙!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.101.203
推 geniuswang35:感恩啊... 10/14 21:25
推 taipei90437: 感恩啊...可不可以提供一下範例 這樣比較清楚 謝謝^^ 10/14 21:56
推 ted7726:天阿好複雜...!! 10/14 23:32
推 pipaho:翻成中文還是不太懂..... 10/15 00:00