📄 http:^^www.cs.wisc.edu^~burnett^cs302^p6_questions.html
字号:
Date: Mon, 11 Nov 1996 17:42:46 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Thu, 07 Nov 1996 19:16:49 GMTContent-length: 1528<head><title>Questions about Program 6</title></head><body><h3>Questions about Program 6</h3><ol><li><i>Is it OK to assume that the user is going to enter a 'Y','y','N',or 'n' when asked if he/she wishes to makean appointment?</i><p>At this point, you should do this type of error-checking.You should have a similar function from a previous assignmentthat you can cut-and-paste into program 6; make sure to changethe prompt accordingly.<p><li><i>If the month,day,hour,etc. entered by the user is invalid,do we just include some sort of default value or can weindicate to the user that his/her answer was invalid and then ask him/her toselect again?</i><p>Since the input is within a member function, it certainly makessense to do the latter. Contrast this with the following: supposeinstead of <b><tt>read_app</tt></b>, you had to write a bunch of<em>writer</em> functions that filled each field one by one.These writer functions would probably do error checking on theirown and assign default values since they don't interact with theuser.<p>To summarize, if the interaction with the user is built into a memberfunction (as it is with <b><tt>read_app</tt></b>), then, if the userenters an invalid value, she should be prompted again for a valid value.If the interaction with the user is <em>not</em> built into a memberfunction (see the <b><tt>HourlyEmployee</tt></b> example), then yourwriter functions should be prepared to assign default values (or nothingat all) to the member variables.<p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -