#how to derive a class
36 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
the assignment is as follows
class GradedActivity{
private:
double score;
public:
GradedActivity()
{score = 0.0;}
GradedActivity(double s)
{score = s;}
void setScore(double s)
{score = s;}
double getScore() const
{return score;}
char getLetterGrade() const;
};
char GradedActivity::getLetterGrade() const{
char letterGrade;
if (score > 89) {
letterGrade = 'A';
} else if (score > 79) {
letterGrade = 'B';
} else if (score > 69) {
letterGrade = 'C';
} else if (score > 59) {
letterGrade = 'D';
} else {
letterGrade = 'F';
}
return letterGrade;
}
The Essay class should determine the grade a student receives on an essay. The student's essay score can be up to 100, and is made up of four parts:
Grammar: up to 30 points
Spelling: up to 20 points
Correct length: up to 20 points
Content: up to 30 points
The Essay class should have a double member variable for each of these sections, as well as a mutator that sets the values of these variables. It should add all of these values to get the student's total score on an Essay.
Demonstrate your class in a program that prompts the user to input points received for grammar, spelling, length, and content, and then prints the numeric and letter grade received by the student.```
i have the code working, but no classes
you can create a class like class Essay { ... }; right?
if you want to derive your new class called Essay from another class called GradedActivity, instead you type class Essay: public GradedActivity { ... };
did you teacher provide you like readings or videos or lectures or anything to learn this? 😅
one thing we wont do here is do your entire homework assignment
no T-T
but if you have any specific questions
like "what does this part of a class mean"
or "what does it mean to derive something from something else"
we're here 
my code works, but its not in the format the teacher wants
uhh
okay i guess you might want to post your code here
specific questions are easier to answer
lets goo
like i said, accomplishes goal, but not the way the teacher wants
brb, need to take dogs out
classes have a lot of fancy names and weird parts, if you have zero knowledge on how classes work this might be tough to explain nicely
if you want someone to walk you through your assignment you might want to check out #tutoring (or i guess you can just cross your fingers someone has the time to drop by and work it through)
i recommend copying that GradedActivity class into your code and start writing some template Essay class
class Essay: public GradedActivity {
... variables that an essay has here ...
.. Essay(...) constructors here ...
... void setXYZ() mutators here ...
}
it works
but i have 22 errors :/
changed a couple of thing, got down to 6, but have 7 messages
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.