English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

form and animate (triangle heptagon hexagon etc) that will rotate four times

2007-02-21 18:50:23 · 2 answers · asked by Anonymous in Science & Mathematics Engineering

2 answers

Not to ignore your question, but why would you want to do anything graphical using C?

2007-02-21 19:03:23 · answer #1 · answered by knowmeansknow 4 · 0 0

permit's start up with what your substantial technique would desire to look like. You created those style of instructions, so which you desire to apply them: Circle c = new Circle(3.5); // 3.5 is the radius Rectangle r = new Rectangle(3.0.5.0); // 3.0 is width, 5.0 is top sq. s = new sq.(8.0); // sq. with factors of 8 device.out.prinln("component of Circle: " + c.section()); device.out.prinln("component of Rectangle: " + r.section()); device.out.prinln("component of sq.: " + s.section()); So, you create shapes from the a number of instructions, and you ask them what their section is. that suggests: Circle desires a constructor that takes a million double that it shops by using fact the radius. Rectangle desires a constructor that takes 2 doubles and shops them as width, top. sq. desires a constructor that takes a million double and shops it as length. and each and each of those instructions needs to override and enforce section. section ought to be declared as returning a double, no longer void. (section interior the form type would desire to truly be declared as precis). in case you're sensible, you would be certain that a sq. is basically a undeniable case of a rectangle, and you will permit the rectangle type do quite some the artwork. Oh, and particular, use Math.PI, and don't bypass it around as a parameter. ETA: What you probably did incorrect is: You did no longer upload a constructor for each shape. working example, Circle would desire to have: Circle(double r) { } You did no longer declare member variables to keep the dimensions of the merchandise. working example, circle needs to bear in recommendations the radius: double radius; Circle(double r) { radius = r; } You did no longer write a community technique for each shape. working example, component of a circle public override double section() { return Math.PI * r * r; }

2017-01-03 07:33:36 · answer #2 · answered by ? 3 · 0 0

fedest.com, questions and answers