Public feed #726216

Someone

public text v1 · immutable
Raw Edit
·published 2007-10-04 23:34 UTC
rendered paste body
Main.cpp

// Fig. 3.13: fig03_13.cpp
// GradeBook class demonstration after separating 
// its interface from its implementation.
#include <iostream>
using std::cout; 
using std::endl;

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

// function main begins program execution
int main()
{
   // create two GradeBook objects
   GradeBook gradeBook1( "CS101 Introduction to C++ Programming", "Professor Spookypants" );
   GradeBook gradeBook2( "CS102 Data Structures in C++", "Professor Smarmosaurus" );

   // display initial value of courseName for each GradeBook
   cout << "gradeBook1 created for course: " << gradeBook1.getCourseName()
      << "\ngradeBook2 created for course: " << gradeBook2.getCourseName() 
      << endl;
   return 0; // indicate successful termination
} // end main



/**************************************************************************
 * (C) Copyright 1992-2008 by Deitel & Associates, Inc. and               *
 * Pearson Education, Inc. All Rights Reserved.                           *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 **************************************************************************/


GradeBook.cpp:

#include <iostream>
using namespace std;

#include "GradeBook.h"

GradeBook::GradeBook( string name, string instructor_name )
{
	setCourseName( name );
	setProfName( instructor_name );
}

void GradeBook::setCourseName( string name )
{
	courseName = name;
}

string GradeBook::getCourseName()
{
	return courseName;
}

void GradeBook::setProfName( string instructor_name )
{
	profName = instructor_name;
}

string GradeBook::getProfName()
{
	return profName;
}


void GradeBook::displayMessage()
{
	cout << "Welcome to the gradebook for " << getCourseName() << "!" << endl;
	cout << "This class is taught by " << getProfName() << "!" << endl;
}


GradeBook.h:

/*
 *  GradeBook.h
 *  Lab1
 *
 *  Created by Ryan Small on 10/4/07.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */

#include <String>
using std::string;

class GradeBook
{
public:
	GradeBook( string );
	void setCourseName( string );
	void setProfName( string );
	string getCourseName();
	string getProfName();
	void displayMessage();
private:
	string courseName;
	string profName;
};