Java

OOP GUIDE / WORK

 

ROUNDTABLE CLASS

 

Topics

  • Simple class design, Using objects

 

 

TASK – PART 1 – ROUNDTABLE CLASS

Create a RoundTable class with the specifications below.  Test your work.

 

  • Instance variables:

    • Diameter – Diameter of the table (in feet)
    • Height – Height of the table
    • Material – Table’s material type (such as “wood”, “steel” or “plastic”)

 

  • One constructor that gets a value for each instance variable.

  • A toString() method that returns a string of the form:

         RoundTable:Diameter=4, Height=3, Material=Wood

  • A method named seatingSpots that returns the number of seating spots possible for a table based on the information in the image below:


 

TASK – PART 2 – TESTING YOUR ROUNDTABLE CLASS

 

In a class called RoundTableTester, inside the main function, create a few RoundTable instances (objects).  Test all of the instance methods.

 

 

TASK – PART 3 – SHORT ANSWER QUESTION

 

A restaurant has 4 round tables in it.  Objects representing these tables have been created and named t1, t2, t3 and t4.  Write the statement needed to calculate the total amount of seating available in the restaurant.