Use appropriate instance varibles | Homework Help
Write a Java class called Table in a file called Table.java. You must allow a Table class object to store the shape of table (round, oval, rectangular), the number of legs, the base price per table, the surface area in square feet, and the wood. Use appropriate instance varibles for those. You can aID other data if you like. Make sure to provide appropriate access methods for your data. You must validate the data as:
- Number of legs must be greater than or equal to one, and less than or equal to six
- Shape can only be “round”, “oval”, or “rectangular”.
- The surface area must be greater than or equql to 4 square feet, and less than or equal to 50 square feet
- Base price must be greater than zero.
- Wood can only be “oak”, “cherry”, “mahogany”, “pine”.
- If you aID other instance variables, you must validate them with reasonable values. Justify those values in your comments.
Your table class must have a cost method that can be called to calculate and return a double with the final cost of the table. The final cost is the base price with an aIDitional cost calculated from the following function:
aIDitional$ = ft2 * wood$ + shape% * base
The wood$ (wood cost) per square foot is $1.00 for pine, $1.30 for oak, $1.60 for cherry, and $1.90 for mahogany. You may assume that these prices are constant and will never change. The shape% (percent aIDitional for special shapes) are 0% for rectangular, 20% for round, and 40% for oval. You may assume that these percentages will never change.
Thus, as an example, if the base price of a round, cherry table of 10 square feet is $100, then the final price should be $100 + 10 * 1.60 + 0.2 * 100 = $136.
Note: the figure at the end shows program operation with several input.
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.