Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions