Question: Java code working is required. Create an entity class Cake and carry out the following: a. Encapsulate information about the following: name and calories (ensure

Create an entity class Cake and carry out the following: a. Encapsulate information about the following: name and calories (ensure you use the principles of encapsulation and information hiding). b. Define 2 overloaded constructors, one with no parameters, the other with parameters corresponding to the above fields; the constructors must ensure that calories can only take values above 0; otherwise, the constructor should throw an appropriate runtime exception. Define setter methods corresponding to each field and, in a similar manner to the constructor, they should ensure the arguments passed satisfy the above conditions. d. Define getter methods corresponding to each field. e. Finally, override the method toString so that it returns the string representation of a cake's details. C.
Step by Step Solution
There are 3 Steps involved in it
public class Cake private St... View full answer
Get step-by-step solutions from verified subject matter experts
