Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following information, located on Github m03, are provided as a starter. Frac.h, a complete Frac Class Declaration ( the definition is to be complete

The following information, located on Github m03, are provided as a starter.

  1. Frac.h, a complete Frac Class Declaration ( the definition is to be complete by you.)
  2. testFrac_starter.cpp, a working program with partial Frac members defined to get you started.

Please follow the TODO List below to finish all Class definitions, and to expand the starter to exercise and verify all the Frac member methods.

Part-1

To complete the definition of all Five (5) Required Frac class method groups:

All items listed below must be verified in your submission!

1. Constructors: * you may combine the first 3 Contructors below into one.

  • Default: numerator default as 0, denominator default as 1
  • One (1) argument Fill Constructor: (int numerator) numerator only, denominator default as 1
  • Two (2) arguments Fill Constructor: (int numerator, int denominator)
  • String Constructor: (string s); where s in the format of "3/4"

2. Necessary getters and setters

3. Support the following operators:

  • basic math: +, -, *. /
  • pre and postfix ++ and -- (4 different types)
  • comparators: <, >, <=, >=, !=, ==

4. Type conversion operators, to convert Frac numbers to integer or floating point numbers:

 cout << " First Frac f1: " << f1 << " Second Frac f2: " << f2 << " 1st fi as Integer: " << int(f1) << " 2nd fi as Double: " << double(f2);

5. Test overload friend iostream insertion <<, and extraction >> operator.

Submit

  1. testFrac.cpp (a starter is provided in Github)
  2. Frac.h or you may combine into one single testFrac.cpp
  3. Verification (All Frac class members test requirement 1-6 must be tested)
  4. Explanation of the different output pattern on running the special ++/-- test provided for this project

Details:

Part-1 (25 pts) for Five groups of member functions:

  • Constructors (inc. string constructor)
  • Getter/setters
  • Math
  • Type cast
  • Friend << and >>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago