Answer to Question #262318 in C++ for ZZZZZ

Question #262318

A parameterized constructor taking 4 arguments for bread slices, cheese slices, meat patty number and tomato slices. The values of the rest of the variables will be initialized by default to true 2. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 3. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 4. Provide setters for mustard, ketchup, iceberg and gilled 5. Provide getters for each of these variables 6. Provide a method calculatePrice() that calculates and returns the price of this sandwich according to the rates given in the above table. E.g. the price of a sandwich with 3 bread slices, 2 cheese slices, 2 tomato slices, 3 patties, mustard, no ketchup, no ice berg with grilling will be calculated as 3 * 20 + 2 * 30 + 2 * 5 + 3 * 70 + 5+ 0 + 0 + 10  


1
Expert's answer
2021-11-07T10:15:25-0500
#include <iostream>
#include <algorithm>


using namespace std;




class Buter {
public:
	Buter(int bread, int cheese, int meat_patty, int tomato, int mustard = 0, int ketchup = 0, int iceberg = 0, int gilled = 0) {
		this->bread = bread;
		this->cheese = cheese;
		this->meat_patty = meat_patty;
		this->tomato = tomato;
	}
	Buter(int mustard, int ketchup, int iceberg, int gilled, int bread = 0, int cheese = 0, int meat_patty = 0, int tomato = 0) {
		this->mustard = mustard;
		this->ketchup = ketchup;
		this->iceberg = iceberg;
	}
	void setMustard(int mustard) {
		this->mustard = mustard;
	}
	void setKetchup(int ketchup) {
		this->ketchup = ketchup;
	}
	void setIceberg(int iceberg) {
		this->iceberg = iceberg;
	}
	void setGilled(int gilled) {
		this->gilled = gilled;
	}
	void setBread(int bread) {
		this->bread = bread;
	}
	void setCheese(int cheese) {
		this->cheese = cheese;
	}
	void setMeat_patty(int meat_patty) {
		this->meat_patty = meat_patty;
	}
	void setTomato(int tomato) {
		this->tomato = tomato;
	}


	int setMustard() {
		return mustard;
	}
	int setKetchup() {
		return ketchup;
	}
	int setIceberg() {
		return iceberg;
	}
	int setGilled() {
		return gilled;
	}
	int setBread() {
		return bread;
	}
	int setCheese() {
		return cheese;
	}
	int setMeat_patty() {
		return meat_patty;
	}
	int setTomato() {
		return tomato;
	}


	float calculatePrice() {
		return bread*20 + cheese*30 + tomato*5 + meat_patty*70 + mustard*5 + ketchup*0 + iceberg*0 + gilled*10;
	}
private:
	int mustard;
	int ketchup;
	int iceberg;
	int gilled;
	int bread;
	int cheese;
	int meat_patty;
	int tomato;
};




int main() {
	
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS