Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE C++. I HAVE ALREADY COMPLETED THE TASK UP TO TASK 5 I NEED HELP WITH TASK 6 AND ONWARDS. I will paste my

image text in transcribed

PLEASE USE C++.

I HAVE ALREADY COMPLETED THE TASK UP TO TASK 5 I NEED HELP WITH TASK 6 AND ONWARDS.

I will paste my code I which I have already completed here.

#include #include #include #include #include #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; }

Task: Create the class "FISH" suitable for a fishmonger's counter, with reference to the Table below. 1. Implement code for all methods, constructors, accessors, mutators, functions, etc, necessary to create objects and automatically populate the class using this data (25%) 2. Draw the UML glyph for the class (5%) . Your code must Ensure Purchase Cost per item is used to automatically determine Selling Price; Ensure the number of units are randomly generated within stated min-max bounds; Ensure the Expiry Date is calculated from the date at the time of data entry (using the clock on the computer). Fish Coc Plaice Salmon Haddock Tuna Mean Weightikel 0.37 0.37 1.30 0.37 0.45 Purchase Cast (/ke) Selling Price /kg) Units (min-max) (EExpiry Date 6.50 2 x Purchase Cost 10-20 Entry Date + 3 5.25 2 x Purchase Cost 10-20 Entry Date + 3 4.50 3 x Purchase Cost 15-25 Entry Date +3 4.00 3 x Purchase Cost 5-15 Entry Date + 3 525 4x Purchase Cost 1-10 Entry Date +3 3. Add functions to the class to calculate the total weight of any given fish and the cost and selling price per unit (9%) 4. Assume the counter begins with a total income of 50. Add a purchasing function that increases stock and decreases income accordingly (10%) 5. Add a unit sale function that decreases stock, logs income and calculates profit, displaying each (11%) 6. Derive a new class "SHELLFISH" from the "FISH" class and populate it using the data in the following Table: (10%) Shellfish Mean Weight (kg) Purchase Cast (E/kg) Selling Price (E/kgUnits (min-max) Mussel 0.05 4.00 4 x Purchase Cost 40-200 Prawn 0.02 6.25 4 x Purchase Cost 50-150 Scallop 0.03 5.50 5 x Purchase Cost 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%) Note: A bonus of 10% will be given if you use a dynamic array to manipulate produce for the store with elements of the array associated with different types of fish/shellfish. You should delete any dynamic objects created once program execution terminates A bonus of 5% will be given if you include a clear example of polymorphism Your class must be rigorously encapsulated (no direct access to class variables) or you will suffer a 5% score penalty

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

find the point(s) of intersection of f(x)=3ln(x) and g(x)=x^1/2

Answered: 1 week ago