Can i make this work with a number specified in the constructor?

Hi everyone
I posted a couple of days ago and i have managed to advance a bit since then.
Here i have a class called "flower" and it draws a flower with two leaves and 12 petals using the classes "petal and "leaf".
However, ideally i would like to be able to make this work with a number of petals specified in the constructor, not just 12.
is this possible or do i need to rewrite the entire class?
import java.awt.*;
import java.awt.geom.*;
public class flower {
    private Shape circle;
    private Shape stem;
    public flower()   {
        circle = new Ellipse2D.Double(-25, -25, 50, 50);
        stem = new Line2D.Double(0.0, 0.0, 0.0, -200.0);
    public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D)g;
    g2.setPaint(Color.green);
    g2.setStroke(new BasicStroke(5)); // Line width 8 pixels
    g2.draw(stem);
    // Add the petals
    petal P = new petal(Color.red);
    // Scale, translate and rotate the petal into place.
    AffineTransform orig  = g2.getTransform();
    AffineTransform T = AffineTransform.getTranslateInstance(0.0, -25);
    for (int k = 0; k < 12; k++) {
      double angle = k*Math.PI/6.0;
      AffineTransform A =  AffineTransform.getScaleInstance(1.0, 1.0);
      A.preConcatenate(T);     // Scale, then rotate
      AffineTransform R = AffineTransform.getRotateInstance(angle);
      A.preConcatenate(R);     // Scale, translate and then rotate
      g2.transform(A);
      P.paint(g);
      g2.setTransform(orig);     // Restore original transform
      g2.setPaint(Color.yellow);
      g2.fill(circle);
      leaf L = new leaf();
      AffineTransform B = AffineTransform.getTranslateInstance(0.0, 0.0);
      B.translate(340, 425);
      B.scale(1.0, 1.0);
      B.rotate (Math.PI/6);
      g2.setTransform(B);     
      L.paint(g);
      g2.setTransform(orig);     // Restore original
      leaf L1 = new leaf();
      AffineTransform C = AffineTransform.getTranslateInstance(0.0, 0.0);
      C.translate(285, 430);
      C.scale(1.0, 1.0);
      C.rotate (Math.PI/-6);
      g2.setTransform(C);     
      L1.paint(g);
      g2.setTransform(orig);     // Restore original
}I am tempted to make "flower into a class that extends "petal" would this make it easier for me to achieve my goal?
Any help would be great
Thanks Carl

Your NewFlower class extends petal. You NewFlower constructor calls super( color, petnum ), so the petal constructor is invoked. In the petal constructor, you ignore petNum. You do nothing else in the NewFlower constructor, so petNum is ignored there as well.
What makes you think that in this orgy of ignoring petNum, that any petNum variable will magically get set, or that your flower will now magically have the right number of petals?
� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • I'm new to mac. Just started out. Have OS 10.8.3. I have an HP 1315 printer.  It prints and copies, wont scan.  I see old threads on this, nothing recent.  ?can i make this work, or do i need a new printer??

    I'm new to mac. Just started out. Have OS 10.8.3. I have an HP 1315 printer.  It prints and copies, wont scan.  I see old threads on this, nothing recent.  ?can i make this work, or do i need a new printer??

    Hi Newbie111
    I see that you are unable to scan with the Photosmart 1315.
    What driver are you using?
    The driver listed in the url below is a basic print driver that will allow you to print only.
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=ps242muc&c c=us&dlc=en&lc=en&os=1006&product=61956&sw_lang=
    You can try using the apple drivers in the url below.
    http://support.apple.com/kb/DL907
    If you have any further issues please let me know.

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to make this work with Firefox, I like not to use microsoft products! HELP!

    Downloading for Realplayer, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. Hoow to make this work with Firefox, I like not to use microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • I cannot access to my iTunes on my computer via my Apple Tv, but it works with my daughter's macbook, how can I make it work with my pc?

    I use to be able to access all my music and videos on my iTunes  via my Apple TV, but since a few months it hasn't work. My daughter tried with her computer and apple ID and it worked, but I want my Library to be accessible. I tried starting it over, rebooting it, but nothing seems to be working.
    How can I make it work?
    Thank you!

    Check firewall and any security software installed on your system. Toggle off/on home sharing on your computer.

  • I seem to be short on space for the trial download. How can I make this work????

    I seem to have less space for my download.How can I make this download happen?????? Will I have to uninstall my old Adobe Photoshop(which has long since worked) in order for this to be installed??

    What exactly are you trying to download on what system? Feel free to download to external drives to bypass the immediate bottleneck, but that may not resolve your issue once you install....
    Mylenium

  • Can I download something from the internet that is only meant for windows? Can I make it work with safari?

    I would like to download a business program from the internet, but it is only meant for windows.  Can I make it work on my mac?

    You are aware that you can purchase and install a copy of Windows directly on your Mac, right?
    Boot Camp is included with OS X, and requires that you create a separate partition for Windows and install it onto your Mac hard drive. You re-boot your Mac computer into Windows when you want to run the Windows app.
    There are also virtual machine environments that will allow you to run full Windows at the same time as Mac OS X:  Parallels Desktop, and VMWare Fusion.
    Windows performance running in a virtual environment will be limited by the amount of RAM available, the microprocessor, and the amount of hard disk space available.
    Parallels offers a free 15-day trial, but you still need a full licensed copy of Windows in order to test it.
    Message was edited by: kostby

  • How can I make it work with my iPad?

    I bought a wireless Hp6500 all in one printer yesterday. It works with my Mac Pro laptop... Now what do I need to make it work with my iPad?

    Is it a 6500 or a 6500A?  If the former, it will not support AirPrint, if the latter it will.
    It has to be connected to your network (wired or wireless, it does not matter), not just to a computer with USB.
    Once connected to your network, enable web services from the front panel of the printer and let it check for updates.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Dialing into conferencing - "sorry I can't find a meeting with that number" but yet the user has that ID assigned

    via my dial in website 24494 is assigned to the user, but when you try to call it I get  "sorry I can't find a meeting with that number".  I know I can reset the ID and it will work but this is the 3rd user that has had this problem. 
    When I do a debug it shows:
    TL_INFO(TF_PROTOCOL) [2]15F8.1B60::01/24/2013-22:26:51.788.000900a4 (SIPStack,SIPAdminLog::ProtocolRecord::Flush:2387.idx(196))[960327338] $$begin_record
    Trace-Correlation-Id: 960327338
    Instance-Id: 8FB48
    Direction: outgoing;source="local"
    Peer: pool:62367
    Message-Type: response
    SIP/2.0 400 pstnMeetingIdNotFound
    Start-Line: SIP/2.0 400 pstnMeetingIdNotFound
    FROM: <sip:[email protected]:5072;transport=Tls;ms-opaque=84495afe39ba64b7>;epid=405FA20A16;tag=f310578fdf
    To: <sip:[email protected];gruu;opaque=srvr:HomeServer:E1afnHoe-VCvSgUhA7OT6gAA>;tag=2711C94508D01F9EE8A863D02A51E2CC
    CALL-ID: 2cfd68ae1e4449d99f9a9b1bb67f710f
    CSEQ: 541 SERVICE
    Via: SIP/2.0/TLS 192.168.205.70:62367;branch=z9hG4bKd82c74c;ms-received-port=62367;ms-received-cid=9C5F00
    Content-Length: 379
    Content-Type: application/cccp+xml
    ms-diagnostics: 3174;reason="An authoritative conference directory was found, but the given id is not currently assigned.";meeting-id="24494";source="LYAPP"
    Message-Body: <response xmlns="urn:ietf:params:xml:ns:cccp" requestId="7" C3PVersion="1" from="sip:[email protected];gruu;opaque=srvr:HomeServer:E1afnHoe-VCvSgUhA7OT6gAA" to="sip:RtcApplication-67758190-5c3b-4f6c-b236-a14357c5f097@com:5072;transport=Tls;ms-opaque=84495afe39ba64b7"
    code="failure">\n<resolveConference reason="pstnMeetingIdNotFound"/>\n</response>
    $$end_record

    Did you do the migration? If so, you have to renew the conference ID.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • How to Create a Dynamic http address that opens the Explorer Window for a List Item When a Button Is Clicked--Currently Trying to Make this Work with Javascript

    I have created a button (via Content Editor) that uses JavaScript to open the Attachments folder of a list item in the Explorer Window in SharePoint 2010. The purpose is to have drag and drop functionality for each list item, having multiple attachments.
    The button works but opens the "Attachments" folder containing all of the other folders for each list item (one folder per item). It seems that when you add an attachment to a list item, SharePoint numbers the folder based on the item's ID. What
    I'm trying to do is take the JavaScript I have and have it run when a button is clicked in a custom form. When it runs, I'm trying to get it to open the "specific" folder for the list item. I have had success creating a hyperlink in the list that
    does this; however, the link WILL NOT work until I use the Content Editor created button that runs JavaScript, that prompts me to click OK to my profile certificate, and then opens the Attachment folder. After that occurs, I can use my hyperlinks without issue
    because I'm no longer prompted to click OK for my cert.
    So I'm trying to take the JavaScript I have and place it in a list item form (custom form) and have it run when a form button is clicked. The problem is I have very little knowledge of JavaScript (did I mention little?) and
    "don't know how to take the "http:" address I have in the script and append to it the list item ID, according to the record I have open."
    So that for any record I open, the script will grab the corresponding record ID (or list item ID) and append it.
    Here's the script I'm working with (which I didn't create but am grateful for):
    <style>
    .httpFolder {behavior:url(#default#httpFolder);}
    </style>
    <script text = "javascript">
       function fnOpenFolderView(){
       oDAV.navigateFrame("https://server/collection/site/subsite/Lists/Sublist/Attachments","_self");
    </script>
    <div id = "oDAV" class = "httpFolder"/>
    <input type = "button" value = "Open Attachment Folder" onclick = "fnOpenFolderView()"/>
    The above script, in the Content Editor, creates a button that opens the Attachments folder for the corresponding SharePoint list.
    JackSki123

    Hello Thriggle,
    Thank you for pointing that out. I appended your "GetUrlKeyValue" to the end and it worked. That said, I noticed it doesn't run as smoothly as when I simply click on the Content Editor button I created that resides on the SharePoint List
    ASPX page (not the form). The Content Editor button has the same code, minus the "GetUrlKeyValue". I click it; I get prompted to choose my cert; it opens right up.
    Now go to the ASPX Display form where I dump the code in a table cell. Button appears in cell; I click it; wait; wait; I get prompted for cert; it opens. Do I need some sort of "throttle" for the JavaScript? For instance, I thought before running
    JavaScript, you reference the library first. This code doesn't do that. I'm wondering if there's something more I need to make this run smoothly. Thank you both for getting me this far. 
    JackSki123

  • Auto capitalisation of the letter I? How can I make this work?

    My macbook Air is great but it doesn't automatically capitalise the letter I which is painful when writing assignments as they are so easy to miss! I tried making a shortcut but you must have more than one character and no spaces. Is there a setting I can change to make it work? Someone please help!!!

    Smiley95 wrote:
    My macbook Air is great but it doesn't automatically capitalise the letter I which is painful when writing assignments
    PS Of course this kind of thing also depends on the app you are using to write with.  Pages 4 can do it, and probably some other apps as well.

  • Can't make this call with Unlimited World trial?

    Trying to make a call to Mexico with +52 and am seeing the insufficient credit message but I just got on the Unlimited World trial.

    According to this forum: http://forum.lowyat.net/topic/2175165/all, it seems that Siri is expecting a 7-8 digit phone numbers excluding the country code and area code, so adding an extra "0" digit or two at the back of the phone number may be able to fix your problem. The phone number should still connect correctly. Try that, it works for me in Indonesia where some phone numbers are still 6 digits.
    Hindra

  • Digger SQL Developer extension 1.1 - How can I make this work?

    I installed it and averything looks fine but I cannot find the option to use it, Does any one knows how to make it work?
    Regards

    Sorry for overlooking this message. Just in case you still need it (yeah, i know :)) it's very easy to use, although I must admit it may be a little confusing at first. Basically you just have to open a trace file, i.e. file with an extension .trc. Digger is triggered by this extension and opens its window inside SQL Developer.
    Dmitry Skavish
    http://www.fourthelephant.com

  • Using XP Professional SP 3 with latestest version of Firefox, the US Airways web site will not work properly. I can still make it work with MS IE

    I am using XP Professional SP 3 with newest version of Firefox, the US Airways web site does not work. I can make the site work with MS Internet Exp. What do I need to change to make Firefox work?

    Can you clarify in which way the site isn't working?
    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.org/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If the new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • I have a Dell v715w printer and can't make it work with my macbook, need help

    I have a Dell v715w printer and am having difficulty making it work with my MacBook Pro, need suggestions.

    Hi,
    The printer do support AirPrint (the HP Deskjet 3525 is part of the 3520 Series).
    Make sure your printer connected to the same router as your iPad and it shold be listed..
    Be aware that you need iOS 4.2 or higher and your router should support Multicasting for AirPrint to work..
    If the printer isn't listed please clarify your router brand and model, some routers don't offer Multicasting or have the protocol disabled by default.

Maybe you are looking for

  • Importing all my music to iTunes(Please help me out)

    Hello, I just purchased a 20gb ipod today and am havintg some trouble importing all of my music. I have complete music library's in "RealPlayer" "Winamp" and "Windows Media Player", it doesnt matter which one of these i import from(whatevers easier i

  • Error in transformation in OSB

    Hi all, I am getting following error in transformation in OSB console: <con:reason>     OSB Assign action failed updating variable "PaymentRequestsPCMToEBS": com.bea.wli.common.xquery.XQueryException: Error parsing XML: {err}XP0006: "element {http://

  • Input requested: Issues in upgrading search for public site to 2013

    We have a fully branded 2010 public site that uses search.  In our upgrade to 2013: We'd would prefer not to perform the visual upgrade because we don't want to update our master pages and page layouts.   Search currently uses a 2010 search scope to

  • How to get the order type from notification number

    Hi, i have the notification number, fromthis number how can i get the Maintenance Order type. what is the table name to get the order type. Please tell me.

  • N85 connects to the internet when having a call.

    Hi all ! Since i've changed my data plan, i've set up my n85 to use 3G networks (before i disabled this function to save battery). So now, everytime i'm having a call, the phone connects to the internet (either via 3G either via wifi). First, is this