Question: JAVA Question 12 and 13 Here is Widget class public class Widget { private String Name=widget; private double Price; public Widget (String Name, double Price){

JAVA

Question 12 and 13

JAVA Question 12 and 13 Here is Widget class public class Widget

Here is Widget class

public class Widget {

private String Name="widget";

private double Price;

public Widget (String Name, double Price){

this.Name=Name;

this.Price=Price;

}

public String getName(){

return Name;

}

public double getPrice(){

return Price;

}

public void setName (String Name){

this.Name=Name;

}

public void setPrice (double Price){

this.Price=price;

}

public String toString(){

return "Name: " +Name +"; Price:$" +Price;

}

public static void main (String[]args){

Widget w = new Widget ("Crafts"+1000);

}

}

12. Write the WidgetChild class. It is a subclass of the Widget class in problem 1. The WidgetChild has an additional instance variable, int x a. Include a constructor that requires input b. Include getters and setters. c. Add a toString) method to the WidgetChild class to print all the information about a WidgetChild. Use the overriden toString() method of the Widget class. 13. Create a WidgetChild object. methods of WidgetChild Using the getters of the class and dot notation, run all the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!