based on the following statement 1What are the problems with

based on the following statement:-

1.What are the problems with this program?
2.How would you solve this problem when developing a Java programs?

3.This program use inheritance or polymorphism?
4.As a programmer, discuss why this technique is very important and benefiting in developing a Java program.

Shape class:
public class Shape {
private int color; // Color of shape
public int getColor () { return color; }
public void setColor (int newColor) { color = newColor; }
}

Circle class:
public class Circle {
private int color; // Color of circle
private double radius; // Radius of circle
private Point center; // Center of circle
public int getColor () {...}

public void setColor (int newColor) {...}
public double getRadius () {...} ...
}

Solution

This program uses inheritance.

In this program we draw the circle. For this we uses radius and to find the area of circle we use pir^2 formula.

While adding colors to the circles we got problems i.e the color options is inside circle or out side of circle and on circle.

These techniques provide more flexibility while draw the circles through programming.

based on the following statement:- 1.What are the problems with this program? 2.How would you solve this problem when developing a Java programs? 3.This program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site