Use appropriate instance varibles | Homework Helpers

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:

Don't use plagiarized sources. Get Your Custom Essay on
Use appropriate instance varibles | Homework Helpers
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

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.

superadmin

Recent Posts

LDR 3302-21.01.01-1A24-S1, Organizational Theory and Behavior

LDR 3302-21.01.01-1A24-S1, Organizational Theory and Behavior Unit III Essay Top of Form Bottom of Form…

3 years ago

Psychology Question | My Essay Helpers

Chapter 9 What are teratogens? Give 5 examples. Define each of these stages: Germinal, embryonic,…

3 years ago

Financial Market Analysis | My Essay Helpers

You are a Financial Analyst that has been appointed to lead a team in the…

3 years ago

Decision theory | My Essay Helpers

This week’s discussion will focus on management decision-making and control in two companies, American corporation…

3 years ago

Literature Question | My Essay Helpers

Mary Rowlandson felt that the man who eventually came to own her, Quinnapin, was “the…

3 years ago