Draw and manipulate simple geometric shapes

Assignment Help Computer Graphics
Reference no: EM13779481

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.

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?
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: EM13779481

Questions Cloud

Efficiency and reducing the profitability of business : Explain whether you believe that there is too little regulation and protection for business in the United States or whether you think that there is too much regulation slowing down the efficiency and reducing the profitability of business in this ..
Reimbursement methodologies class : Review each of the four components of the revenue cycle (Preclaims, Claims, Accounts Receivable, and Claims, reconciliation and collections) and identify a key staff member involved in each of the four components.
Provide the six sigma process : A product has specification limits of 6.0 ounces and 6.5 ounces.  The company of this product states that the product weighs 6.2 ounces. If the company wants to have a Cpk of 2.0 or greater, what is the maximum value of the standard deviation (?) so ..
How is justice defined : Justice is one of the five core ethical principles in healthcare. Does the article discuss justice in terms of procedural or distributive justice? How is justice defined?
Draw and manipulate simple geometric shapes : You are developing a simple graphics package that will allow you to draw and manipulate simple geometric shapes such as squares, rectangles, etc
Number of applications or tuition costs : Using a regression model, if a question states that a college believes that decreases in number of student applications are directly and linearly related to tuition prices, what would be the Y Range (number of applications or tuition costs)?
Discussion on leadership and motivation : Next, state whether or not you think such leadership characteristics are innate or learned. Provide a rationale for your response
What guaranteed mileage should the manufacturer announce : A new extended-life light bulb has an average service life of 768 hours, with a standard deviation of 45 hours. If the service life of these light bulbs approximates a normal distribution, about what percent of the distribution will be between 617 ho..
Business mapping of processes issue : What causes these? What is the impact on cycle times?

Reviews

Write a Review

Computer Graphics Questions & Answers

  What is cadastral surveying and mapping what is spatial

1.what is cadastral surveying and mapping?2.what is spatial data information sdi?3.what is the bathurst declaration and

  Organized to focus more on organizational

As you probably have noted, this course is organized to focus more on organizational and enterprise level issues than on individual or group behavior. There are other courses in the program that allow you the opportunity to reflect on lower le..

  Media effects theories

Mass Media EffectsThe study of mass media effects has a long and storied history that predates the existence of the communication discipline itself. Yet, its breadth and scope have made it challenging for the area to gain coherence.

  Develop a five-year strategic plan with cost estimates and

develop a five-year strategic plan with cost estimates and a time line.describe the situation facing mensa at the time

  Given a 2-d point at position 20 30 show the results and

given a 2-d point at position 20 30 show the results and intermediate steps for a translation of 10 35 a rotation of 45

  Bundled attribute what is bundled attribute types of

what is bundled attribute ? ltbrgttypes of bundled attribute? ltbrgtexplain abount over all bundled atttribute?

  Write a narrative that describes how about designing

Write a narrative that describes how you went about designing and implementing these modifications, how you tested your program. Did you use the test case during development or did you use the final words.txt from the start, or what?

  Modify the single-cycle datapath to implement ''add tozero''

Modify the single-cycle datapath to implement an instruction called 'add to zero' (addz). The 'addz' instruction adds two registers and stores the result in a register and also in the memory at address zero.

  Securing and protecting information

Discuss how this and other information security considerations will affect the design and development process for new information systems.

  Specify a triangle with three mouse presses

Write a program that allows the user to specify a triangle with three mouse presses. After the first mouse press, draw a small dot. After the second mouse press, draw a line joining the first two points.

  Modifying the product program through gui

Modify the product Program to use a GUI. The GUI should show the data one product at a time, including the product number, the name of the item, the number of units in stock.

  Rewrite programming to create a gui

Rewrite Programming Exercise to create a GUI. Your probram should let the user eanter the loan amound and loan period in the the number of years from the tests fields and it should sisplay the monthly and total payments for each interest rate start..

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