# CIS 278 Project 5 The QUAD CLASS solution

\$24.99

Original Work ?

## Description

You are to implement a Quad class, such that you have both a ‘header file’ and an ‘implementation file ’ (see Chapter 11). The header file, Quad.h, provides class declaration and identifies public and private class members. The implementation file provides definitions for all member and friend functions.

A Quad object represents a Quadratic expression of degree 2, that is: ax2 + bx + c
For this assignment, the coefficients a, b and c are restricted to integers.

Public functions:
Effect: create a Quadratic with a,b and c set to 0

Effect: creates a Quadratic with a=0, b=0, c = value

Quad(int a, int b, int c)
Effect: creates a Quadratic with the specified parameter values as coefficients

int eval(int value) const
Effect: evaluates the Quadratic for x = value
Returns: the computed result
For example, if the Quad equation was: 2×2 + 2x + 1
And method eval was called with value = 2, eval would return 14 ( 2*22 + 2*2 + 1)

int& operator[](int index)
Effect: set/access method for the coefficient of xindex
Returns: the coefficient of xindex

Postcondition: this object and qu are unchanged
Returns: a new Quad object which is termwise sum of this object and qu

Effect: Compare this Quad to another object p to see if they are equal
Postcondition: this Quad object is unchanged
Returns:
A return value of true indicates that p refers to a Quad object
the same value as this Quad object. False is returned otherwise.

const Quad multiple(int value) const //member function
Effect: new Quad object is created in which each coefficient is a multiple of this object
Postcondition: this object is not changed
Returns: new object where each coefficient is ‘value times’ the coefficient of this object
(ie. this object a=2, b=4, c=3, value=6; new object a = 12, b =24, c = 18)
const Quad operator-() const // unary minus member function
Effect: new Quad object created identical to this one except coefficients are negated
Postcondition: this Quad object is unchanged
Returns: the new object

const Quad operator++() // autopreincrement member function
Effect: new Quad object created identical to this one after data is incremented
Postcondition: this Quad object coeffiecient are incremented by one
Returns: the new object

const Quad operator++(int) // autopreincrement member function
Effect: new Quad object created identical to this one before data is incremented
Postcondition: this Quad object coeffiecient are incremented by one
Returns: the new object