course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

Fraction.h

// Fraction.h contains class Fraction and its operation prototypes.
//
//  Author:
//  Date:
//********************************************************************

#ifndef FRACTION #define FRACTION

// replace this line with the beginning of class Fraction

// replace this line with the beginning of the public section

//******************************************************** // Fraction default-value constructor function. * // Precondition: A Fraction object has been declared. * // Postcondition: myNumerator == 0 && myDenominator == 1.* //******************************************************** // replace this line with the prototype of the 1st Fraction constructor

//******************************************************** // Fraction explicit-value constructor function. * // Precondition: A Fraction object has been declared. * // Receive: numerator, denominator, two integers. * // Postcondition: myNumerator == numerator && * // myDenominator == denominator. * //******************************************************** // replace this line with the prototype of the 2nd Fraction constructor

//******************************************************** // Numerator extractor * // Return: the value of myNumerator. * //******************************************************** // replace this line with the prototype of Numerator()

//******************************************************** // Denominator extractor * // Return: the value of myDenominator. * //******************************************************** // replace this line with the prototype of Denominator()

//******************************************************** // Input function member * // Receive: in, an istream. * // Precondition: in contains a Fraction n/d. * // Input: n/d via in. * // Passback: in, with n/d extracted from it. * // Postcondition: myNumerator == n && myDenominator == d.* //******************************************************** // replace this line with the prototype of Read()

//******************************************************** // Output function member * // Receive: out, an ostream. * // Output: myNumerator and myDenominator via out. * // Passback: out, containing the output values. * //******************************************************** // replace this line with the prototype of Print()

//******************************************************** // operator* * // Receive: rightOperand, a Fraction object. * // Return: result, the product of the receiver of * // this message and rightOperand. * //******************************************************** // replace this line with the prototype of operator*

//******************************************************** // Simplify a Fraction from improper to proper. * // Postcondition: the Fraction receiving this message * // is a proper fraction. * //******************************************************** // replace this line with the prototype of Simplify()

// replace this line with the private section

// replace this line with the end of class Fraction

// *** Simple Member Functions ***

// replace this line with the definition of the 1st Fraction constructor

// replace this line with the definition of the 2nd Fraction constructor

// replace this line with the definition of Print()

// replace this line with the definitions of the 2 extractors

// *** Simple Non-Member Operations *** //******************************************************** // operator>> * // Receive: in, an istream object, * // aFraction, a Fraction object. * // Pass Back: in, with a fraction extracted from it. * // aFraction, filled with that fraction. * // Return: in (for chaining). * //********************************************************

inline istream & operator>>(istream & in, Fraction & fract) { fract.Read(in); return in; }

//******************************************************** // operator<< * // Receive: out, an ostream object, * // aFraction, a Fraction object. * // Pass Back: out, with aFraction inserted into it. * // Return: out (for chaining). * //********************************************************

inline ostream & operator<<(ostream & out, const Fraction & fract) { fract.Print(out); return out; }

#endif

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Thursday, November 15, 2001 at 3:29:36 PM.
visitors to this page.