Answer to Question #255617 in C++ for sana

Question #255617

You are required to build a class to represent the a cup of coffee. Call your class 

CoffeeCup. A coffee cup will have following characteristics 

1. type (sting) // can be mocha, cupaccino, etc 

2. temperature (float): 

3. volume (float):

4. sugar (int): 

Provide these methods 

1. parameterized constructor CoffeeCup(string t, float temp float vol, int sug) 

2. Provide setters for temperature, and sugar and volume. 

3. Provide getters of temperature, sugar, volume and type. 

4. void heatUp():

5. void cooldown(): the process of cooling down. The temperature goes down by one degree but 

will not go below 0 

6. bool isSweet():

7. bool hasMore(): 

8. bool isEmpty(): 

9. bool takeASip(): 

10. Provide a method print, that displays the status of the cup with respect to all data members.


1
Expert's answer
2021-10-24T00:40:23-0400
#include<iostream>
using namespace std;
class CoffeeCup{
	private:
		string type;
		float temperature;
		float volume;
		int sugar;
	public:
		CoffeeCup(string t, float temp, float vol, int sug) {
			type =t;
			temperature = temp;
			volume = vol;
			sugar = sug;
		}
		void setTemp(string t){
			type =t;
		}
		
		void setVolume(float vol){
			volume = vol;
		}
		void setSugar(int sug){
			sugar = sug;
		}
		
		float getTemp(){
			return temperature;
		}
		int getSugar(){
			return sugar;
		}
		
		int getVolume(){
			return volume;
		}
      void heatUp(){
      	temperature++;
	  }
	  
	  void  cooldown(){
	  	temperature--;
	  }
	  
	  bool isSweet(){
	  	if(sugar==0){
	  		return false;
		  }
		else{
			return true;
		}
	  }
	   bool hasMore(){
	   	if(volume !=0){
	   		return true;
		   }
		else{
			return false;
		}
	   }
	   bool isEmpty(){
	   	if(volume !=0){
	   		return true;
		   }
		else{
			return false;
		}
	   }
    void takeASip(){
    	volume--;
	}
	
	void print(){
		cout<<"Type:  "<<type<<endl;
		cout<<"Volume: "<<volume<<endl;
		cout<<"Temperature:  "<<temperature<<endl;
		cout<<"Sugar:   "<<sugar<<endl;
	}
};


int main(){
}

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