C++帮帮忙作业
1 Replace the standard datatype (int in the ItemType class, String in the StringLogInterface and ArrayStringLog class) with a class Program which includes:
the title of the program (ex: "Revolution", "American Idol")
the day of the week when the program is broadcast (Sunday, Monday, Tuesday, etc.) -- assume that each program is shown only one day a week, at one time.
the time of the program (ex: 11:30am, 9:00pm) -- you are free to choose how you represent this
how long the program lasts, in 30 minute increments (30 minutes, 1 hour, 90 minutes, ...)
Write a driver program to run the program. Offer options to:
Get the name of the channel for this data -- ex: ABC, HBO
'A' to add a program to your listing. You may assume all inputs are valid, so you don't have to worry about a show on "Funday", for example. You do need to reject the addition if the program overlaps an existing program -- again, this is for only one channel, and we are assuming this is the "regular" schedule, so you don't need to account for programming specials or changes to the schedule.
'P' to print a schedule, ordered by day of the week and then time. Any time slot which does not have a program may be omitted or left blank. Here is what the start of the output might look like:
ABC
Sunday
8:00am Morning News
9:00am Football pregame
10:00am Football
1:30pm Football postgame
'F' to find a program (ask for the title of the program). If it is found, you should list the program details. If it is not found, display an error message.
[解决办法]
顶一下,国外的C++作业
[解决办法]
>replace the standard datatype (int in the ItemType class, String in the StringLogInterface and ArrayStringLog class)
standard datatype : ItemType, StringLogInterface, ArrayStringLog?
你确定你说的是C++?
除却诡异的ItemType, StringLogInterface, ArrayStringLog,这题目应该不难实现
可以用STL的话,算是挺简单的
我翻译一下原文的大意 :
程式的功能是允许user输入monday~sunday的日子,输入以后就显示出当天有什么节目
不需要考虑user会输入奇怪的日子,所以没有必要检查
按'A'可以选择加入节目,如果该时段已经有节目存在,则不允许加入新节目
节目的时间以半小时为一播放单位(节目A~节目B的时间可以11~11.30,11~12,11~13.30等)
按'P'可以印出目录,若某段时间没有节目可以忽略不印或印出空白
输入'F'可以搜寻节目,找到则列印节目的细节
没找到则印出错误讯息
不难,但是建资料有点麻烦
[解决办法]
既然是作业我觉得还是自己做会比较好
[解决办法]
看起来 要继承重写ItemType, StringLogInterface, ArrayStringLog类 的int及string类型
类似于用类实现 结构体 学生成绩 添加查询
[解决办法]
>看起来 要继承重写ItemType, StringLogInterface, ArrayStringLog类 的int及string类型
照你说的,楼主的题目应该给的不完整吧?
至少也要列出ItemType, StringLogInterface, ArrayStringLog的定义
以及这些class是拿来干嘛的
只是把名字打出来我们知道出题者想拿这些class来做什么?
难不成这一题是在考验我们的读心术吗?
[解决办法]
不熟悉 个人看法 大概应该是这样 错误是难免的 仅提供一个看法
class myclass:public ItemType, StringLogInterface, ArrayStringLog
{
private:
typedef int Myint;
typedef string Mystring;
public:
Mystring title;
Myint wday;
Myint mday;
Myint sec;
Myint min;
Myint hour;
Mystring Program;
myclass::GetParameter(Myint letter);
myclass::GetData(Myint letter);
myclass::WriteData(Myint letter);
}
myclass::myclass()
{
title="American Idol";
}
myclass::GetParameter(Myint letter)
{
switch(letter)
{
case 'A':WriteData(FILE *f);
case 'P':GetData(FILE *f)
default:return;
}
}
myclass::GetData(FILE *f)
{
Mystring str;
getline(f,wday);
cout<<wday<<endl;
getline(f,hour);
cout<<hour<<" ";
getline(f,min);
cout<<min<<" ";
getline(f,sec);
cout<<sec<<" ";
getline(f,str);
cout<<str<<endl;
}
myclass::WriteData(FILE *f)
{
tm mytime;
gettime(mytime);
Mystring str;
sec=mytime.tm_sec;
min=mytime.tm_min;
hour=mytime.tm_hour;
wday=mytime.tm_wday
f<<wday<<endl<<hour<<" "<<min<<" "<<sec<<'\t'<<str<<endl;
}
[解决办法]
写成一个BHO 驱动其实就是读写BHO的内容