I need help with **Java programming** for these questions, please do each of the
ID: 3771870 • Letter: I
Question
I need help with **Java programming** for these questions, please do each of them as seperate questions and not as a whole.
Write a constructor for the table class that will accept two input arguments as the initial values of the attributes Write an overloaded constructor for the Table class that will take a single argument for the color of the table Write a set method (also known as a mutator method) for the color attribute. Write a get method (also known as accessor method) for the color attribute. Complete a main method that will accomplish the following: You may assume that the class includes all appropriate set methods (also known as mutator methods) and get methods (also known as accessor methods). The output can be completed using console output or GUI input Create a blue kitchen table with 4 legs Create a brown dining table with 6 legs Change the color of the kitchen table to be pink Print out the color of the dining table including text identifying which value you are printing and also the value itself. Print out the number of tables including text identifying which value you areExplanation / Answer
(1)
Table(String color, int no_of_legs)
{
this.color = color;
this.no_of_legs = no_of_legs;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
(2)
Table(String color)
{
this.color = color;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------
(3)
public void set_color(String color)
{
this.color = color;
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------
(4)
public String get_color()
{
return this.color;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------
(5)
public static void main(String args[])
{
Table kitchen_table = new Table("Blue" , 4);
System.out.println("*** Kitchen Table ***");
System.out.println(" Color: " + kitchen_table.get_color() + " No Of Legs: " + kitchen_table.get_no_of_legs());
Table dining_table = new Table("Brown" , 6);
System.out.println(" *** Dining Table ***");
System.out.println(" Color: " + dining_table.get_color() + " No Of Legs: " + dining_table.get_no_of_legs());
kitchen_table.set_color("Green");
System.out.println(" Changing Color of Kitchen Table.....");
System.out.println(" Color: " + kitchen_table.get_color() + " No Of Legs: " + kitchen_table.get_no_of_legs());
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.