【发布时间】:2021-11-30 06:27:28
【问题描述】:
给定一个类 Movie (id, title, ranking, release date, character number, ticket price, comment etc.)、enum type: ACTION, COMEDY, DRAMA, FANTASY etc. 和一个类 Cinema (name, location)。我需要编写一个函数calculateProfit ( Movie*, day),它会根据某个特定日期计算电影院的利润。我还需要编写一种基于某些参数选择电影的方法,并根据发行日期对电影进行排序。我已经考虑这个问题几天了,但似乎我无法编写正确的代码。
为了能够根据参数选择电影,我需要获取具有相同特定属性的 Movie 类的所有对象的列表。我该怎么做?
这是我的课程的简要模板:
using namespace std;
class Movie{
public:
int ID;
string Title;
int Ranking;
string ReleaseDate;
int CharacterNumber;
int TicketPrice;
string Comment;
//SortingByDate
enum type{
ACTION, COMEDY, DRAMA, FANTASY
} Type;
Movie(int, string, int, string, int, int, string, type);
Movie();
};
Movie::Movie(int ID, string Title,int Ranking,string ReleaseDate,int CharacterNumber, int TicketPrice,string Comment, type Type){
this->ID=ID;
this->Title=Title;
this->Ranking=Ranking;
this->ReleaseDate=ReleaseDate;
this->CharacterNumber=CharacterNumber;
this->TicketPrice=TicketPrice;
this->Comment=Comment;
this->Type=Type;
class Cinema{
private:
int calculateProfit();
public:
//Vector with objects of Movie class
string name;
string location;
};
【问题讨论】:
-
"
//Vector with objects of Movie class"。std::vector<Movie> movies;似乎不见了。 -
对于您班级的教授、班级的教师助理或与您的同学的合作来说,这听起来像是一个很好的问题。
-
您能不能至少给我们一个示例查询?这是您今天迄今为止提出的第三个问题,除了一般问题陈述之外,您的输入为零。您的老师是否希望您过滤一个属性?五?有什么属性吗?什么样的过滤?相等还是字符串匹配?您希望如何处理结果?
-
我仍然不明白如何计算利润。
Movie没有包含足够的信息来计算给定日期的利润。
标签: c++ oop methods attributes