• 0

[C++] Modifying Class GradeBook


Question

Hai guys!

As some of you may know I am very new to the C++ programming world and need help getting started.

Here is my problem:

(Modifying Class GradeBook) Modify class GradeBook as follows:

A) Include a second string data member that represents the course instructor's name.

B) Provide a set function to change the instructor's name and a get function to retrieve it.

C) Modify the constructor to sepcify two prameters--one for the course name and one for the instructor's name.

D) Modify member function displayMessage to output the welcome message and course name, then the string "This is presented by: "followed by the instructor's name, then the string "This course is presented by "followed by the instructor's name.

This is what I have so far, I need allot of assistance piecing the rest of the stuff so if any of you guys can give me the "full picture" I'd appreciate it greatly

GradeBook.cpp

  Quote
// Fig. 3.12: GradeBook.cpp

// GradeBook member-function definitions. This file contains

// implementations of the member functions prototyped in GradeBook.h.

#include <iostream>

using std::cout;

using std::endl;

#include "GradeBook.h" // include definition of class GradeBook

// constructor initializes courseName with string supplied as argument

GradeBook::GradeBook( string name )

{

setCourseName( name ); // call set function to initialize courseName

} // end GradeBook constructor

// function to set the course name

void GradeBook::setCourseName( string name )

{

courseName - name; // store the course name in the object

} // end function setCourseName

//function to get the course name

string GradeBook::getCourseName()

{

return courseName; // return object's courseName

} // end function to getCourseName

// display a welcome message to the GradeBook user

void GradeBook::displayMesasge()

{

// call getCourseName to get the courseName

cout << "Welcome to the grade book for\n" << getCourseName()

<< "!" << endl;

} // end function displayMessage

GradeBook.h

  Quote
// Fig. 3.11: GradeBook.h

// GradeBook class definition. This file presents GradeBook's public

// interface without revealing the implementations of GradeBook's member

// fucntions, which are defined in GradeBook.cpp.

#include <string> // classs GradeBook uses C++ standard string class

using std::string;

// GradeBook class definition

class GradeBook

{

public:

GradeBook( string ); // constructor that initializes courseName

void setCourseName( string ); // function that sets the course name

string getCourseName(); // function that gets the course name

void displayMessage(); // function that displays a welcome message

private:

string courseName; // course name for this GradeBook

}; // end class GradeBook

Link to comment
https://www.neowin.net/forum/topic/670616-c-modifying-class-gradebook/
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Your first step is to make the class schema changes in the header:

class GradeBook
{
	public:
		GradeBook( string );
		void setCourseName( string );
		string getCourseName();
		void displayMessage();

		void setInstructorName(string);
		string getInstructorName();

	private:
		string courseName;
		string instructorName;
};

After you have done this, its just simply making additions to the .cpp file:

void GradeBook::setInstructorName(string name)
{
	instructorName = name;
}

string GradeBook::getInstructorName()
{
	return instructorName;
}

void GradeBook::displayMessage()
{
	cout &lt;&lt; "Welcome to the gradebook for: " &lt;&lt; getCourseName() &lt;&lt; endl;
	cout &lt;&lt; "This couse is presented by " &lt;&lt; getInstructorName() &lt;&lt; endl;
}

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Anker announces global recall of five power bank models over fire safety risks by Aditya Tiwari The Chinese electronics brand, Anker Innovations, known for its mobile accessories and power banks has announced a voluntary global recall of five power bank models. The decision comes after the company spotted a potential fire hazard issue with lithium-ion battery cells from a particular vendor. Anker said that it put up a series of quality checks to detect manufacturing issues early in the production cycle, which include component level-audits and supplier testing. The company assured that "while the likelihood of malfunction is considered minimal, out of an abundance of caution, we have decided to initiate a voluntary global recall of several Anker power bank models." Here's the list of the Anker Power Bank models chosen for the global recall: Model A1257 - Anker Power Bank (10K, 22.5W) Model A1647 - Anker Power Bank (20,000mAh, 22.5W, Built-In USB-C Cable) Model A1652 - Anker MagGo Power Bank (10,000mAh, 7.5W) Model A1681 - Anker Zolo Power Bank (20K, 30W, Built-In USB-C and Lightning Cable) Model A1689 - Anker Zolo Power Bank (20K, 30W, Built-In USB-C Cable) If you think you own one of the affected power banks, you can check the model number located on the back or side of your power bank. After that, you can fill out the recall form to start the process and verify the serial number of your affected device. If your power bank is eligible for the recall, you can either get a replacement or receive a gift card for use on the Anker website. It's not offering any refunds in the US at the moment. Anker advises that you should stop using an impacted power bank immediately even if the device functions normally right now. A unit confirmed for the recall could pose the risk of overheating, melting, smoke, or fire. This is the second major recall from Anker in the same month after more than a dozen reports of fires and explosions. The company previously recalled over one million Anker PowerCore 10000 (A1263) power bank units, citing fire safety risks due to a potential issue with the Lithium-ion battery. These power banks were sold in the US from January 1, 2016 through December 31, 2022.
    • What learning curve !!?? Govt office employees never learn anything !! they're just there to not work !!
    • "The entire scanning and conversion process takes place locally on your device, using Android’s built-in API for snapping documents. The document itself is also only stored locally until you decide to send it. Just like other WhatsApp messages, these scans are secured with end-to-end encryption when you send them to recipients. The only privacy risk is the user sending the PDF to the wrong person."
    • It is a great product though... in this case, I don't mind paying.
  • Recent Achievements

    • Collaborator
      Mighty Pen went up a rank
      Collaborator
    • Week One Done
      emptyother earned a badge
      Week One Done
    • Week One Done
      DarkWun earned a badge
      Week One Done
    • Very Popular
      valkyr09 earned a badge
      Very Popular
    • Week One Done
      suprememobiles earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      568
    2. 2
      +FloatingFatMan
      189
    3. 3
      ATLien_0
      179
    4. 4
      Skyfrog
      112
    5. 5
      Xenon
      110
  • Tell a friend

    Love Neowin? Tell a friend!