Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// Measurable.java
public interface Measurable {
double getPerimeter();
double getArea();
}
================================
// Line No 1 : We have to write the implements interface name in Rectangle class
// Rectangle.java
public class Rectangle implements Measurable {
private double width;
private double height;
/**
* @param width
* @param height
*/
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
/**
* @return the width
*/
public double getWidth() {
return width;
}
/**
* @param width
* the width to set
*/
public void setWidth(double width) {
this.width = width;
}
/**
* @return the height
*/
public double getHeight() {
return height;
}
/**
* @param height
* the height to set
*/
public void setHeight(double height) {
this.height = height;
}
@Override
public double getPerimeter() {
// TODO Auto-generated method
stub
return 2 * (width + height);
}
@Override
public double getArea() {
// TODO Auto-generated method
stub
return width * height;
}
}
==========================================
// Test.java
public class Test {
public static void main(String[] args)
{
Rectangle r1=new
Rectangle(6,7);
System.out.println("Area
:"+r1.getArea());
System.out.println("Perimeter
:"+r1.getPerimeter());
}
}
=======================================
Output:
Area :42.0
Perimeter :26.0
=====================Could you plz rate me well.Thank
You
m The interface Measurable is defined as the following: /** An interface for methods that return...
Consider the following declaration for a class that will be used to represent rectangles. public class Rectangle { private double height; private double width; public Rectangle() { height = 2.0; width = 1.0; } public Rectangle(double w, double h) { height = h; width = w; } public double getHeight() { return height; } public double getWidth() { return width; } public void setHeight(double h) { height = h; } public void setWidth(double w) { width = w; } //Other...
I Need UML Design for the following Java code: Colorable interface: public interface Colorable { //a void method named howToColor(). void howToColor(); } GeometricObject class: public class GeometricObject { } Sqaure class: public class Square extends GeometricObject implements Colorable{ //side variable of Square double side; //Implementing howToColor() @Override public void howToColor() { System.out.println("Color all four sides."); } //setter and getter methods for Square public void setSide(double side) { this.side = side; } public double getSide() { return...
Create a Java Project in Eclipse with the following: Include the Rectangle class supplied below. Override the toString method for Rectangle. Override the equals method for Rectangle. Implement the comparable Interface for Rectangle (Compare by area) Rectangle class: public class Rectangle { private double length; private double width; public Rectangle(double l, double w) { length = l; width = w; } public double getLength() { ...
package rectangle; public class Rectangle { private int height; private int width; public Rectangle(int aHeight, int aWidth) { super(); height = aHeight; width = aWidth; } public int getHeight() { return height; } public int getWidth() { return width; } public void setHeight(int aHeight) { height = aHeight; } public void setWidth(int aWidth) { width = aWidth; } public int...
(((
Using Only The mentioned Concepts Solve the following question
in DETAILS “ Take your time but don’t disappoint me
plleeaasseee”:
1- Control structure (if/if else/while/for/switch/do while/
break continue)
2- Functions
3- Arrays
4- pointers and strings
5- classes
6- file processing
)))
if it was a program i need to see the code printed on computer
and the output too please .
10. Write a C++code that include two classes: Rectangle and Triangle as shown below: #include <iostream> using...
Receiveing this error message when running the Experts code below please fix ----jGRASP exec: javac -g GeometricObject.java GeometricObject.java:92: error: class, interface, or enum expected import java.util.Comparator; ^ 1 error ----jGRASP wedge2: exit code for process is 1. ----jGRASP: operation complete. 20.21 Please code using Java IDE. Please DO NOT use Toolkit. You can use a class for GeometricObject. MY IDE does not have access to import ToolKit.Circle;import. ToolKit.GeometricObject;.import ToolKit.Rectangle. Can you code this without using the ToolKit? Please show an...
Hello I have a question. I would like to check if the code follows this requirement. Rectangle.h - A complete Rectangle Class including both declaration and definition appRectangle,cpp separate in two different files the class definition and implementation Code: rectangle.h // Rectangle class declaration. class Rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; //************************************************** // setWidth assigns a value to the width member. * //************************************************** void...
Why are obj1 and obj2 printing the same areas? I'm trying to learn about Comparable interface. Couldn't figure it out. the compare to method should print 0, 1, or -1 import java.util.*; public class RectangleMain { public static void main(String [] args) throws CloneNotSupportedException { /*ComparableRectangleAlsoCloneable obj1 = new ComparableRectangleAlsoCloneable(4, 5); ComparableRectangleAlsoCloneable obj2 = (ComparableRectangleAlsoCloneable)obj1.clone(); System.out.println(obj1.toString()); System.out.println(obj1 == obj2); //false System.out.println(obj2.toString());*/ Scanner...
****Here is the assignment **** Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods to access and update the instance variables’ values, along with other methods to perform calculations. Also, write a test class that instantiates the first class and tests the class’s constructor and methods. Details: Create a class called Rectangle containing the following: Two instance variables, An instance variable of type double used...
I need help with my java code i am having a hard time compiling it // Cristian Benitez import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; import javax.swing.JPanel; Face class public class FaceDraw{ int width; int height; int x; int y; String smileStatus; //default constructor public FaceDraw(){ } // Getters and Setters for width,height,x,y public int getWidth(){ return width; } public void setWidth(int width){ this.width=width; } public int getHeight(){ return height; } public void setHeight(int height){ this.height=height; } public int getX(){ return...