Write a program to test your class myrectangle.

Assignment Help JAVA Programming
Reference no: EM13940996

Create a class named MyRectangle to represent rectangles. The required data fields are width, height, and color. Use double data type for width and height, and a String for color. Suppose that all rectangles are the same color. Use a static variable for color. You will need to provide the accessor methods for the properties and a method findArea() for computing the area of the rectangle.

Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java source code.

The outline of the class is given as follows:

public class MyRectangle{

private double width = 1;
private double height = 1;
private static String color = "white";

public MyRectangle(){

}

public MyRectangle(double widthParam, double heightParam, String colorParam){

}

public double getWidth(){

}

public void setWidth(double widthParam){

}

public double getHeight(){

}

public void setHeight(double heightParam){

}

public String getColor(){

}

public static void setColor(String colorParam){

}

public double findArea(){

}
}

Write a program to test your class MyRectangle. In the client program, create two MyRectangle objects. Assign a width and height to each of the two objects. Assign the first object the color red, and the second, yellow. Display all properties of both objects including their area.

Reference no: EM13940996

Questions Cloud

Determine the stated interest rate on the bonds : Determine the stated interest rate on these bonds. Calculate the interest expense and the discount amortization for the interest period ending June 30, 2010.
Analysis on existing personal skills and knowledge : A SWOT analysis on existing personal skills and knowledge, and skills that need to be developed in the future in order to succeed in study and work.'
Formulate a research specification : Formulate a research specification with the following features: a) Title/research question.
Understanding of external and internal environments : You should demonstrate a clear understanding of the external and internal environments of your choice. What the Macro and Micro factors are and the kinds of influences each one includes.
Write a program to test your class myrectangle. : Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java sourc..
Risk associated with each security independently : The management of Pitsos Ltd is considering the following two investments. The returns of these new projects depend on the state of the economy and they are shown below.
Determine what interest expense for the bond issue : Determine what interest expense for this bond issue Dingle will report in its 2010 income statement. Indicate how these bonds will appear in Dingle's December 31, 2012, balance sheet.
Determine a suitable receiver capacity : Determine a suitable receiver capacity if the maximum allowable number of starts per hour for the compressor is 20.
Criteria relevant to primark in their new market selection : Detail the macro and micro criteria that would be relevant to screen the markets. Why are these criteria relevant to Primark in their new market selection

Reviews

Write a Review

JAVA Programming Questions & Answers

  What are the three types of errors

What are the three types of errors that you can encounter in a Java program? Describe them, and explain how you would minimize the errors

  Please write the code in java nbsprecursionimplement a

please write the code in java nbsprecursionimplement a subsetgenerator that generates all subsets of the characters of

  Create a calorie counter application

Create a calorie counter application. The user should be able to set a daily calorie maximum using preferences. Individual meal entries can be entered for the day and all information will be saved to a local file (Not SQLite)

  Describe the usefulness of the jframe class

What is a JFrame? Describe the usefulness of the JFrame class

  Temporarily move to the street so that the

Driveway is a "last-in, first-out" stack. Of course, when a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave

  Build a thread system

Identify all Nachos classes that you will modify and where you plan to do you modifications - Identify all classes that you plan to implement and give the API for each class,

  Java program to find solution of cryptarithmetic puzzle

A solution to puzzle is S=9, R=8, O=0, M=1, Y=2, E=5, N=6, D=7. Write down a java program which finds solution to cryptarithmetic puzzle of: TOO + TOO + TOO + TOO = GOOD.

  Create java applet to input miles driven and gallons used

Create the Java applet which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and display miles per gallon obtained for each tankful.

  Create a virtual directory

Create a Web archive file and attach to this assignment. Do not copy (cut and paste) any example code, create your own code and use the examples as a guide.

  Design a class named linearequation

(Algebra: 2 X 2 linear equations) Design a class named LinearEquation for a 2 X 2 system of linear equations.

  Qr codes are a popular way

QR codes are a popular way to encode data for easy reading by computerized cameras. True QR codes contain error correction, format specifiers, version information, and a size variable layout that makes them harder to decode and process

  Write a java program that accepts a positive long integer

Write a Java program that accepts a positive long integer between 2 to 15, and then using the number, calculate its factorial (n!). Using do-while statement, make sure it only accepts a valid number (between 2 and 15) - if an invalid number is ent..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd