Flaw in your design and outline

Assignment Help Computer Graphics
Reference no: EM13165508

You are developing a simple graphics package that will allow you to draw and manipulate simple geometric shapes such as squares, rectangles, etc. Your initial design is along the following lines:

public class Rectangle {

   private int h, w;

   public int getHeight() {...}

   public int setHeight(int x) {...}

   ...

}

public class Square extends

Rectangle {

   // ???

}

This question has a 'devil's advocate' nature to it and is in two parts.

1. You intend to model a square as inheriting from a rectangle. How would you complete the code on the above right to realize this intention?

2.No matter how you do design the code for the square, you will be able to write code that will break the meaning of what it means to be a square or rectangle. After completing Part a, discuss the flaw in your design and outline some code that will cause it to break (your code should compile fine and will also execute without an error but will violate how a rectangle or square should behave).

Reference no: EM13165508

Questions Cloud

People must be in a group in order to guarantee : How many people must be in a group in order to guarantee that two people in the group have the same birthday (don't forget leap year)?
This function should accept a two-dimensional : getLowestInRow. This function should accept a two-dimensional array as its argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the lowest value in the specif..
Considered to be an improved version : Part (c) is considered to be an improved version of Part (b). You may use an array (2-dimessional) to store some values that has been computed during the run so that when making recursive calls the program does not compute certain values over and ..
What mass of this substance must evaporate : What mass of this substance must evaporate in order to freeze 112 of water initially at 18? (The heat of fusion of water is 334 the specific heat of water is 4.18 .
Flaw in your design and outline : After completing Part a, discuss the flaw in your design and outline some code that will cause it to break (your code should compile fine and will also execute without an error but will violate how a rectangle or square should behave).
Calculate the mole percent composition of the mixture : Calculate the weight percent composition of the mixture, using the same assumptions as in part A.
Modify the book class to accommodate multiple authors : modify the Book class to accommodate multiple authors using one of the components from the Java Collection Framework.
What is the empirical formula of the hydrocarbon : 4.236-g sample of a hydrocarbon (CxHy) is combusted in O2 completely to give 3.810 g of H2O and 13.96 g of CO2. What is the empirical formula of the hydrocarbon?
Write a test program that prompts the user : public static int binaryToDecimal(String binaryString)Write a test program that prompts the user to enter a binary string and displays its decimal equivalent.

Reviews

Write a Review

 

Computer Graphics Questions & Answers

  Develop a grayscale image consisting of grid

Develop a grayscale image consisting of an 8 x 8 grid with vertical line in the first column. Compress into JPEG format and decompress.

  Develop the image manipulations

Develop the image manipulations

  Creating temperature conversion gui application

Create a temperature conversion GUI application that changes from Fahrenheit to Celsius. The Fahrenheit temperature should be entered from the keyboard and Enter pressed.

  Design a program that show passing arguments byval and byref

Require to design a program that show passing arguments ByVal and then ByRef. It is suggested that I create a square function process and get an integer from the user then send it ByVal one time.

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  How many minutes of uncompressed digital video can be stored

Approximately how many minutes of uncompressed digital video could be stored and played from a standard (single-speed) CD-ROM at 640 X 480 resolution using 256 colors?

  Create menu or appropriate gui for material parameters

Create menu or appropriate GUI for material parameters. Users should be able to manipulate the parameters for material; ambient, diffuse, specular in each RGB channel and shininess.

  Describe hardware flow control''s advantage over software

Describe hardware flow control's advantages over software flow control in terms of improving modem speed.

  Java applets based question

Class Graphics contains technique draw Oval, which takes as discussions the same 4-arguments as method drawRect.

  Determine transfomation of triangle

Determine a transfomation of triangle A(1,0),B(0,1),c(1,1)by:- a) rotating 45 degreeabout origin and then translatingin x and y direction.

  Equation for tangent cubic spline using mspline and mgeom

We are given the following boundary conditions for cubic spline section: Give equation P0(u) for tangent to this curve in terms of Mspline and Mgeom.

  Question about troubleshooting problem

Consider the most difficult troubleshooting problem you have encountered in your recent experience- one where the solutions was not straightforward

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