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

  Product ordering system and design

Product Ordering System and Design Document:Select a company and one of its products for which you will be creating an online ordering system. Get your instructor's approval for your selections

  Write a recursive method to print all permutations of string

Write a recursive method to print all the permutations of a string. For instance, for a string abc, the printout is: abc acb bac bca cab cba

  Design and implement a java program that will gather info

Design and implement a Java program that will gather a user's first name, middle initial, lastname, age in years, and 3 lucky numbers. The program should output the following based on the user's input

  Method that reads a text file and returns a list of tokens

Write a method that reads in a text file and returns a list of the tokens (preferably alphanumeric) in that file. Write a method to print out frequency results.

  Write a recursive instance method

Write a recursive instance method

  Write a program that prompts the user for a start date

You need to write a program that prompts the user for a start date and an end date and then prints all of the dates between them (inclusive), with seven tab-separated dates on each line.

  What is object-oriented programming

What is object-oriented programming? What are the differences between a class and an object

  Write a java program consisting of pigdriver and pig

You will write a Java program consisting of PigDriver and Pig.java, that must Display a welcome message, "Let's Play Pig", Display a blank line and Prompt for the name of the human player.

  Traditionally-nutrition programs were targeted to indigent

Traditionally, nutrition programs were targeted to the indigent and poor populations in developing countries. Many of today's Americans are malnourished also, but they are glutted with a wealth of unhealthy foods and require a multidisciplinary appro..

  Implement a distributed banking application

In the first part, you will implement a distributed banking application. The distributed bank has multiple branches. Every branch knows about all other branches.

  Create java application to add a contact into contact table

Develop a Java application to add a contact into the contact table, and display all contacts in the contact table. The contact table contains two columns, FullName, and PhoneNumber. Both values are text data.

  Create class called hospital and add all relevant attributes

Create a class called Hospital and add all the relevant attributes for the created class - Create a User's super class that contains all the properties common to the all the users that will be using the Hospital patient billing system.

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