Question: Get classPoint and classFraction Please read my notes before proceeding with the assignment. NOTES: 1. I have a classFraction and a classPoint already settled down.
Get classPoint and classFraction
Please read my notes before proceeding with the assignment.
NOTES:
1. I have a classFraction and a classPoint already settled down. Please follow the same functions that I already have (Some of them are must used according to the assignment).
2. The assignment is basically to create a main menu, calling submenus to initialize (to create/update), to place, to move, to flip and to display the Points provided by user.
3. We will be using fractions to be placed, moved, flipped, compared... in a cartesian plane (quadrant 1, quadrant 2, quadrant 3, quadrant 4). we supposed to compared the fractions from the center (0, 0).
4. The user will provide 2 Points (which is equal to four fractions). With the calling functions from the main menu, the program should be able to perform the initializing, placement, moving, flipping and displaying of the fractions.
5. I pasted my codes so you can use those functions and classes. You can add more functions as needed. But please, avoid to change the prototype functions as possible.
6. Feel free to create a simple menu with submenu callings (the main menu is called at main), and please send the reference of a pointer to make changes. THANKS in advance.
#ifndef FRACTION_H
#define FRACTION_H
#include
using namespace std;
//Function Prototype
class Fraction {
public:
Fraction();
Fraction(int); // take it out this one if you can
Fraction(int, int);
Fraction(const Fraction&);
~Fraction();
bool operator>(const Fraction&); // you shoudl add this one // compare one fraction with another fraction
bool operator
bool operator>(int);
bool operator
Fraction& operator+=(const Fraction&);
void setNum(int); // Function Member to set numerator
void setDenom(int); // Function Member to set denominator
int getNum(void) const; // Function Member to get numerator. get back the value
int getDenom(void) const; // Function Member to get denominator
int getCommondBF(int, int) const; // get common factor
void update(int, int); // update
void print(void) const; // print current Fraction object
friend ostream & operator
out
return out;
}
private:
int num;
int denom;
};
#endif
//
#include
#include "fraction.h"
#include "Point.h"
using namespace std;
//Function Definition
Fraction::Fraction() : num(0), denom(1) {
}
Fraction::Fraction(int n) : num(n), denom(1) {
}
Fraction::Fraction(int n, int d) : num(n), denom(d) {
int commonFactor;
if (denom
num = -num;
denom = -denom;
}
commonFactor = getCommondBF(num, denom);
num /= commonFactor;
denom /= commonFactor;
}
Fraction::Fraction(const Fraction& that) :
num(that.num), denom(that.denom) {
cout
}
Fraction::~Fraction() {
//delete xPtr;
//xPtr = nullptr;
//delete yPtr;
//yPtr = nullptr;
}
bool Fraction::operator>(const Fraction& that) {
if (num * that.denom > denom * that.num) {
return true;
}
else {
return false;
}
}
bool Fraction::operator
if (num * that.denom
return true;
}
else {
return false;
}
}
bool Fraction::operator>(int that) {
if (num > (that = denom))
return true;
else return false;
}
bool Fraction::operator
if (num
return true;
else return false;
}
void Fraction::setNum(int n) {
int num;
int commonFactor;
num = n;
num
commonFactor = getCommondBF(num, denom);
num /= commonFactor;
}
int Fraction::getNum() const {
return num;
}
void Fraction::setDenom(int d) {
int denom;
int commonFactor;
denom = d;
commonFactor = getCommondBF(num, denom);
denom /= commonFactor;
}
int Fraction::getDenom() const {
return denom;
}
int Fraction::getCommondBF(int n, int d) const {
int gcd = 1;
int tmp = (num
for (int i = 2; i
if (tmp % i == 0 && denom % i == 0)gcd = i;
return gcd;
}
void Fraction::print() const {
cout
cout
}
void Fraction::update(int n, int d) {
int commonFactor;
num = n;
denom = d;
if (denom
num = -num;
denom = -denom;
}
commonFactor = getCommondBF(num, denom);
num /= commonFactor;
denom /= commonFactor;
}
//
#ifndef POINT_H
#define POINT_H
//#include
//using namespace std;
#include "fraction.h"
//Function Prototype
class Point {
public:
Point();
Point(const Point& that);
Point(int, int, int, int);
int getQuadrant(void) const;
int getQuadrant(const Point&);
void moveBy(const Fraction& delX, const Fraction& delY);
void moveBy(int iOld);
void flipByX();
void flipByY();
void flipThroughOrigin();
void print() const;
private:
Fraction* xPtr;
Fraction* yPtr;
};
#endif
//
#include
#include "fraction.h"
#include "Point.h"
using namespace std;
//Function Definition
Point::Point() :
x(Fraction()), y(Fraction()) {
}
Point::Point(const Point& that) :
x(Fraction(that.x)), y(Fraction(that.y)) {
}
Point::Point(int xn, int xd, int yn, int yd) :
x(Fraction(xn, xd)), y(Fraction(yn, yd)) {
}
int Point::getQuadrant() const {
int quadrant = 0;
if ((x > that.x) && (y > that.y)) {
quadrant = 1;
}
else if ((x that.y)) {
quadrant = 2;
}
else if ((x
quadrant = 3;
}
else if ((x > that.x) && (y
quadrant = 4;
}
else {
quadrant = 0;
}
return quadrant;
}
int Point::getQuadrant(const Point& that) {
int quadrant = 0;
return quadrant;
}
void Point::moveBy(const Fraction& delX,
const Fraction& delY) {
x += delX;
y += delY;
}
void Point::moveBy(int iOld) {
}
void Point::flipByX() {
}
void Point::flipByY() {
}
void Point::flipThroughOrigin() {
}
void Point::print() const {
cout
x.print();
cout
y.print();
}
//
#ifndef FRACTIONUTILITY_H
#define FRACTIONUTILITY_H
//Function Prototype
void menuHw1Ex5(void);
void menuInit(Fraction*&, Fraction*&);
void build2Points(Fraction*&, Fraction*&);
void menuUpdate(Fraction*&, Fraction*&);
void placement(Fraction*&, Fraction*&);
void moving(Fraction*&, Fraction*&);
void flipping(Fraction*&, Fraction*&);
void displaying(Fraction*&, Fraction*&);
#endif
//
#include
#include "fraction.h"
#include "fractionUtility.h"
#include "Point.h"
using namespace std;
//Function Definition
void menuHw1Ex5() {
int option;
Fraction* xPtr = nullptr;
Fraction* yPtr = nullptr;
do {
cout
"* MENU - HW #5 * "
"* 1. Initializing (2 Points) * "
"* 2. Placement * "
"* 3. Moving * "
"* 4. Flipping * "
"* 5. Displaying * "
"* 6. Quit * "
"*******************************"
cout
cin >> option;
switch (option) {
case 1:
cout
menuInit(xPtr, yPtr);
break;
case 2:
cout
if (!xPtr || !yPtr) {
cout
"are available!"
}
else {
placement(xPtr, yPtr);
}
break;
case 3:
cout
if (!xPtr || !yPtr) {
cout
"are available!"
}
else {
moving(xPtr, yPtr);
}
break;
case 4:
cout
if (!xPtr || !yPtr) {
cout
"are available!"
}
else {
flipping(xPtr, yPtr);
}
break;
case 5:
cout
if (!xPtr || !yPtr) {
cout
"are available!"
}
else {
displaying(xPtr, yPtr);
}
break;
case 6:
cout
break;
default:
break;
}
} while (option != 6);
delete xPtr;
xPtr = nullptr;
delete yPtr;
yPtr = nullptr;
}









CIS25-C++ Programming: Homework #5-Page 1 of 9 Homework #5 Turn In: I. Exercise #1-Due in class on Thursday, November 9, 2017 a) For cach exercise, a hardcopy package must be generated to include the following tems - Cover Sheet (use the sample copy include in class/lecture note) - Exercise/problem statement Copy of your source file (C++ program named as cis25Spring2018YournameHw5Ex1.cpp) - Copy of output (copy and paste to the end of your program as PROGRAM - Copy of a COMMENT block on Logic Code Output Issues (as a scparatc - All other supportive files of fractionYourName.h, fractionYourName.cp OUTPUT COMMENT block) comment block) after your PROGRAM OUTPUT fractionUltilityYourName.h, fractionUtilityYoutName.cpp PointYourName.h, PointYourName.cpp, PointUltilityYourName.h PointUtilityYoutName.cpp, ctc b) Submitting in class one hard copy for cach exercise c) Emailing cach document as follows - One message for cach exercise - Attaching the source file that was created in Part a) -The SUBJECT line of the message should have the following line cis25Spring2018YourNameHw5Exl 3. Q.E.D CIS25-C++ Programming: Homework #5-Page 2 of 9 1. Code Assignment/Exercise EXERCISE 1 Consider the following classes: CIS25-C++ Programming: Homework #5-Page 1 of 9 Homework #5 Turn In: I. Exercise #1-Due in class on Thursday, November 9, 2017 a) For cach exercise, a hardcopy package must be generated to include the following tems - Cover Sheet (use the sample copy include in class/lecture note) - Exercise/problem statement Copy of your source file (C++ program named as cis25Spring2018YournameHw5Ex1.cpp) - Copy of output (copy and paste to the end of your program as PROGRAM - Copy of a COMMENT block on Logic Code Output Issues (as a scparatc - All other supportive files of fractionYourName.h, fractionYourName.cp OUTPUT COMMENT block) comment block) after your PROGRAM OUTPUT fractionUltilityYourName.h, fractionUtilityYoutName.cpp PointYourName.h, PointYourName.cpp, PointUltilityYourName.h PointUtilityYoutName.cpp, ctc b) Submitting in class one hard copy for cach exercise c) Emailing cach document as follows - One message for cach exercise - Attaching the source file that was created in Part a) -The SUBJECT line of the message should have the following line cis25Spring2018YourNameHw5Exl 3. Q.E.D CIS25-C++ Programming: Homework #5-Page 2 of 9 1. Code Assignment/Exercise EXERCISE 1 Consider the following classes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
