Question: #ifndef _LAB3_FLUID_ #define _LAB3_FLUID_ #include using namespace std; //This Class is used to store fluid measurements //Remember: // 2 pin = 1 firkin // 2
#ifndef _LAB3_FLUID_
#define _LAB3_FLUID_
#include
using namespace std;
//This Class is used to store fluid measurements
//Remember:
// 2 pin = 1 firkin
// 2 firkin = 1 kilderkin
// 3 kilderkin = 1 hogshead
// You should never store 2 firkin in the kirkin variable, 3 kilderkin in the kilderkin var, etc
// 4 firkin needs to be store as 2 kilderkin and 0 firkin
//You may assume that the set and constructors only receive inbound inputs.
//The user won't say setPins(7).
//For the addition operator, you will need to fix the values after addition.
class fluid
{
private:
int pins_;
int firkins_;
int kilderkins_;
int hogsheads_;
public:
//Constructor
fluid(int p=0, int f=0, int k=0, int h=0);
//Accessors
int getPins() const;
int getFirkins() const;
int getKilderkins() const;
int getHogsheads() const;
//Return the total in pins
int totalPins() const;
//Mutators
void setPins(int p);
void setFirkins(int f);
void setKilderkins(int k);
void setHogsheads(int h);
};
//Boolean Comparisons
bool operator<(fluid a, fluid b);
bool operator>(fluid a, fluid b);
bool operator==(fluid a, fluid b);
bool operator<=(fluid a, fluid b);
bool operator>=(fluid a, fluid b);
//Add Fluids
//(2 hogsheads, 1 kilderkins, 1 firkins, 1 pins)
//+ (3 hogsheads, 2 kilderkins, 0 firkins, 1 pins)
//--------------------------------------------
//(6 hogsheads, 1 kilderkins, 0 firkins, 0 pins)
fluid operator+(fluid a, fluid b);
//Print out as (H hogsheads, K kilderkins, F firkins, P pins)
ostream & operator<<(ostream & out, const fluid a);
#endif
The above file is fluid.h
Given the above:
Create a fluid.cpp file and implement all the methods and operators prototyped in the header file.
Create a task2.cpp file and use it to test your implementation of the fluid class.
Part 2: Max
In task2.cpp write a template function max that takes three inputs of the same type. The function should find the max of the three items.
Write tests that show your max function works correctly with your fluids class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
