Write a program to test your class myrectangle

Assignment Help JAVA Programming
Reference no: EM131578686

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.0;
private double height = 1.0;
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: EM131578686

Questions Cloud

Define a class called incometax : define a class called IncomeTax. The class accepts a value represeting the individuals income - define the percentage as class constants
Which of the persons may be more prone to a mood disorder : Which of the persons may be more prone to a mood disorder? Apply the most current DSM criteria. What are some of the treatment strategy risks or consequences?
Explain how cctv systems can cause more crime : Explain how CCTV systems can cause more crime for delinquents and do you think public attitudes towards CCTV systems differ by age and or gender
Write a java application titled mystringtest : Write a Java application titled MyStringTest that creates an instance of the String class and initializes this instance with a String literal.
Write a program to test your class myrectangle : 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
The role of politics in public health : Do you agree or disagree with Pisani's message about the role of politics in public health?
Types of grid frameworks like bootstrap : Then move your discussion into CSS Grids. What advantages or disadvantages would CSS Grids offer over the old types of grid frameworks like Bootstrap?
Expand common text message abbreviations : Output a message for each abbreviation that is expanded, then output the expanded line - Check for abbreviations in the order provided
What are the three levels of the federal court system : What are the three levels of the federal court system. Which court is at the top of the federal court system

Reviews

Write a Review

JAVA Programming Questions & Answers

  How many employee objects exist in the heap

Assume you have a class called Employee whose constructor takes two arguments: the employee's name and id number

  Program to calculate the payment amount for 3 mortgage loans

Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans

  Implement the hierarchy for a university with java classes

Implement the above hierarchy for a university with Java classes and their appropriate relationship. You can go three levels deep in the hierarchy (community member, employee, student, alumnus, faculty, staff).

  Create a second version of the program

Create a second version of the program in which the two threads cannot invoke atomic concurrently. Write a Java program that has a method named atomic()

  Modify the given program to use a loop to output

This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height

  Javascript program that asks the use

Design a javascript program that asks the user for a username with at least eight characters, beginning with a letter and including at least one digit. Next, write a validation loop to ensure that these conditions have been met

  Create an application containing an array

Create an application containing an array that stores 10 integers. The application should call five methods that in turn (1) display all the integers

  How to access to elements of document object model

To limit creation of malicious code, do you believe that access to elements of document object model and some Javascript functionality be limited?

  Advantage of a multilevel page table over

Suppose that a machine has 38-bit virtual addresses and 32-bit physical addresses. (a) What is the main advantage of a multilevel page table over a single-level one?

  Java implementations of bubble sort

The first project involves benchmarking the behavior of Java implementations of bubble sort, itinvolves writing the code to perform the benchmarking of the bubble sort algorithm.

  Design a class that can be used to hold information

Implement and design a class that can be used to hold information about a musical note - Prepare a complete java program the default constructor should set a note to a middle C quarter note.

  Hashtable and the hashmap

In JAVA programming: What are the differences between a Hashtable and the HashMap? Few examples

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