Question
I will post the code I have already completed the language I used is C++ thank you. #include #include #include #include #include #include using namespace
I will post the code I have already completed the language I used is C++ thank you.
#include
using namespace std;
class FISH{ private: string name; double weight; double purchasedCost; int unit; double amount; char *date; public: FISH(){ time_t ttime = time(0); tm *gmt_time = gmtime(&ttime); gmt_time->tm_mday+=3; if(gmt_time->tm_mday>30){ gmt_time->tm_mday%=30; gmt_time->tm_mon++; if(gmt_time->tm_mon>11){ gmt_time->tm_mon%=12; gmt_time->tm_year++; } } date = asctime(gmt_time); } void setName(string s){ name=s; if(name=="Cod"){unit=rand()%11+10;} if(name=="Plaice"){unit=rand()%11+10;} if(name=="Salmon"){unit=rand()%11+15;} if(name=="Haddock"){unit=rand()%11+5;} if(name=="Tuna"){unit=rand()%1+1;} } void setMeanWeight(double d){weight=d;} void setPurchasedCost(double d){purchasedCost=d;} void setAmount(double s){ amount=s; } char* getExpireDate(){ return date; } string getName(){return(name);} double getMeanWeight(){return(weight);} double getTotalWeight(){return(unit*weight);} double getPurchasedCost(){return(purchasedCost);} double getTotalPurchasedCost(){return(unit*weight*purchasedCost);} double getSellingPrice(){ int n=-1; if(name=="Cod" || name=="Plaice"){n=2;} if(name=="Salmon" || name=="Haddock"){n=3;} if(name=="Tuna"){n=4;} return(n*purchasedCost); } double getTotalSellingPrice(){ int n=-1; if(name=="Cod" || name=="Plaice"){n=2;} if(name=="Salmon" || name=="Haddock"){n=3;} if(name=="Tuna"){n=4;} return(unit*weight*n*purchasedCost); } int getUnit(){return(unit);} double getAmount(){ return(amount); } bool purchase(int n){ double amt=purchasedCost*n*weight; if(amount>=amt){ unit+=n; amount-=amt; return true; } return false; } bool unitSell(int n){ if(unit>=n){ unit-=n; int n1=0; if(name=="Cod" || name=="Plaice"){n1=1;} if(name=="Salmon" || name=="Haddock"){n=2;} if(name=="Tuna"){n=3;} double amt=purchasedCost*n*weight*n1; amount+=amt; cout
void initialize(FISH *fish){ fish[0].setAmount(50); fish[0].setName("Cod"); fish[0].setMeanWeight(.37); fish[0].setPurchasedCost(6.5); fish[1].setAmount(50); fish[1].setName("Plaice"); fish[1].setMeanWeight(.37); fish[1].setPurchasedCost(5.25); fish[2].setAmount(50); fish[2].setName("Salmon"); fish[2].setMeanWeight(1.3); fish[2].setPurchasedCost(4.5); fish[3].setAmount(50); fish[3].setName("Haddock"); fish[3].setMeanWeight(.37); fish[3].setPurchasedCost(4); fish[4].setAmount(50); fish[4].setName("Tuna"); fish[4].setMeanWeight(.45); fish[4].setPurchasedCost(6.25); }
int main(){ srand(time(NULL)); FISH *fish=new FISH[5]; initialize(fish); bool b=false; cout
cout
cout
cout
cout
cout
system("pause"); return 0; }
6. Derive a new class SHELLFISH from the FISH class and populate it using the data in the following Table: (10%) Shellfish Mussel Prawn Scallop Mean Weight (kg) 0.05 0.02 0.03 Purchase Cost (/kg) 4.00 6.25 6.50 Selling Price (/kg) 4 x Purchase Cost 4 x Purchase Cost 5 x Purchase Cost Units (min-max) 40-200 50-150 20-100 Expiry Date Entry Date + 2 Entry Date + 2 Entry Date + 2 7. Add a function to the "SHELLFISH class to calculate the number of packets of prawns in stock given that each packet holds 30 prawns (10%) 8. Add a function to enable the sale of prawns in packets, calculate and display the cost per packet of prawns and the profit from the sale of each packet, updating stock and income as necessary (10%) 9. Write main() code that uses the fish and shellfish classes to manipulate produce at a fish counter, with a user interface that facilitates sales and purchases (10%)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started