Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an entity class Cake and carry out the following: a. Encapsulate information about the following: name and calories (ensure you use the principles

 

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. C. 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Databases questions

Question

What is cultural tourism and why is it growing?

Answered: 1 week ago