You are required to build a class JewelleryItem. A jewellery Item has a type (string) , price (float),
material (string), daysToGo (int).
These attributes represent the type i.e ‘ear ring’, necklace, finger ring etc. The material can be gold,
silver, plastic etc. The daysToGo attribute represents the number of days it will remain fit for use.
1. You are required to provide the following parameterized constructors
JewelleryItem(string type, float price, string material, int daysToGo)
Jewlleryitem(string type, float price, int daysToGo) // the material will get “gold” as default
JewelleryItem(string type, float price) //the material defaults to gold and daysToGo defaults to
100.
2. Now provide getters for each of the attributes above but setters for only price, daysToGo
3. Provide a function/method makeUse(). This function represents the use of this item for one day
which reduces the daysToGo by 1. This function returns true if the daysToGo is greater than 1 and
false otherwise. This means that the item can be used if the daysToGo has not become zero.
4. Provide another function bool polish(int goodForDays). This function represents the scenario that
the jewelry item has been polished and can be used for goodForDays more days. But this function
will work only for the items whose material is gold or silver. E.g if j.polish(100) is called, then if the
item j is made of gold or silver than the daysToGo is increased by 100 days.
5. Provide function print() that prints all the data members.
6. Test your program by writing main and calling different functions.
You are required to build a class ArithematicProblem that represent a binary
arithematic problem such as addition, subtraction, multiplication and division.
The ArithematicProblem class is a super class which is there to provide the most
generic version of the ArithematicProblem concept. This class has following
instance variables
1. Operator1 (double)
2. Operator2 (double)
3. Answer(double)
4. Error(boolean)
The value of Operator1 and Operator2 will be initialized through parameters in the
constructor while the value of answer is Double.POSITIVE_INFINITY and error is false
by default.
Provide getters for all but setters for only operand1 and operand2
Provide the toString method so that the string representation of each operation
the standard representation in mathematics i.e. if its an addition problem then it
should be printed as 2 + 3 = 5 and so on.
Provide a method double solve() in this class. This method performs the arithematic
operation on the operands, calculates answer, sets the value of answer and returns it. If an error occurs
in the calculation then the error is set to true and answer remains Double.POSITIVE_INFINITY. Since in
the super class ArithematicProblem, we do not know what to do (beccause it is not one of the standard
4 operations), you will simply return the answer (Double.POSITIVE_INFINITY)
Now provide the subclasses AdditionProblem, SubtractionProblem,
MultiplicationProblem and DivisionProblem. All of these class inherit from
ArithematicProblem. Provide appropriate constructors and the toString method.
Now override the solve method in each of these class to do the appropriate
operation. i.e. If it is AdditionProblem then you will add the operands in the solve
method, set the answer to the sum obtained and return this value.
In subtraction you will do subtration and multiplication the product. However, in division, you will
perform the division but if the divisor i.e. the second operand is 0 then the division goes into error. So
you will check for this situation and if the divisor is 0 then you will not solve, rather set the error to true
and return the answer unchanged. (I.e. POSITIVE_INFINITY, the default value).
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more
Recent Comments