Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <sstream>
using namespace std;
class Icecream
{
private :
string flavour;
int noOfScoops;
int price;
public :
Icecream()
{
}
Icecream(string flavour, int noOfScoops) {
setFlavour(flavour);
setNoOfScoops(noOfScoops);
setPrice(noOfScoops * 99);
}
string getFlavour() const {
return flavour;
}
void setFlavour(string flavour) {
this->flavour = flavour;
}
int getNoOfScoops() const{
return noOfScoops;
}
void setNoOfScoops(int noOfScoops) {
if (noOfScoops < 0)
throw
runtime_error("This is not a valid number of scoops");
else
this->noOfScoops = noOfScoops;
}
int getPrice() {
return price;
}
void setPrice(int price) {
this->price = price;
}
string toString() {
stringstream ss;
ss<<noOfScoops<<"
Scoop(s) of " << flavour << " ice cream cost " <<
getPrice()<< " cents.";
return ss.str();
}
};
int main()
{
Icecream ic1("Vanilla", 1);
Icecream ic2("cookie dough", 2);
try {
cout<<ic1.toString()<<endl;
cout<<ic2.toString()<<endl;
ic1.setNoOfScoops(-1);
} catch(runtime_error& x) {
cout << x.what() << endl;
}
ic2.setFlavour("strawberry");
cout<<ic2.toString()<<endl;
return 0;
}
___________________________
Output:
_______________Could you plz rate me well.Thank
You
ise 1. Create a new project named lab6 1. You will be implementing an IceCream class. For the class attributes, let'...
In this lab, you will be writing a complete class from scratch, the IceCreamCone class. You will also write a driver to interact with a user and to test all of the IceCreamCone methods. Lab: • Cone • Ice Cream o Flavor o Topping • Ice Cream Cone • Driver Part I: Cone An ice cream cone has two main components, the flavor of ice cream and the type of cone. Write a Cone class that takes an integer in...
JAVA PROGRAMMING***** Please provide screenshots of output and write a tester class to test. The starter code has been provided below, just needs to be altered. For this project you will implement the Memento Design Pattern. To continue on with the food theme, you will work with Ice Cream Cones. You will need to use AdvancedIceCreamCone.java. Create at least three Ice Cream Cones - one with chocolate ice cream, one with vanilla ice cream and one with strawberry ice cream....
I need the following written in Java please, thank you ' We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...
FOR C++ PLEASE Create a class called "box" that has the following attributes (variables): length, width, height (in inches), weight (in pounds), address (1 line), city, state, zip code. These variables must be private. Create setter and getter functions for each of these variables. Also create two constructors for the box class, one default constructor that takes no parameters and sets everything to default values, and one which takes parameters for all of the above. Create a calcShippingPrice function that...
Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string +Contact() //default constructor sets all attribute strings to “unknown”; no other constructor +setName(string name) : void +setPhone(string pn) : void +setEmail(string em) : void +getName() : string +getPhone() : string +getEmail() : string +printContact() : void //print out the name, phone numbers and email address Create New Project Name your project: CIS247_Lab7_YourLastName. For this exercise, you may use a header file or one file...
its about in C++ You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task and Appointment which inherit from the Event class The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which designate the time of the event It should also have an integer member called id which should be a...
JAVA programing Question 1 (Date Class): 5 Points Create a class Date with the day, month and year fields (attributes). Provide constructors that: A constructor that takes three input arguments to initialize the day, month and year fields. Note 1: Make sure that the initialization values for the day, month and year fields are valid where the day must be between 1 and 31 inclusive, the month between 1 and 12 inclusive and the year a positive number. Note 2:...
JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...
Design a class named Month. The class should have the following private members: • name - A string object that holds the name of a month, such as "January", "February", etc. • monthNumber - An integer variable that holds the number of the month. For example, January would be 1, February would be 2, etc. Valid values for this variable are 1 through 12. In addition, provide the following member functions:• A default constructor that sets monthNumber to 1 and name...
Lab 3 Step One First, create an empty directory for lab3. There is no starter code for this lab. You will be throwing and catching exceptions in this exercise. Create a file called RuntimeException.h and put the following code in it. #include <string> class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } } Step Two In a new .cpp file in your directory, write a main function...