Polymorphism.  Problems with my Element Objects

As far as I know, my problem is I keep getting my Objects confused with one another. I was wondering if someone could help me please.
Eyerything works in my abstract class and supporting classes. My application is where the issues are. It goes:
public class PlayElementOOPS
public static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
//Data
ElementSet anES;
Element anE;
String classId;
Play2 aPlay;
Playwright aPW;
String possible;
double maybe;
boolean done = false;
int choice;
//Logic...
anES = new ElementSet();
while(!done)
System.out.print("\nPlease enter the option you wish the program to " +
          "perform.\n\n1) Add a Play\n2) Add a "+
          "Playwright\n3) Remove a Play\n" +
          "4) Remove a Playwright\n5) Diplay all Plays\n" +
          "6) Display all Playwrights\n7) Display by a " +
          "given Playwright\n8) Display all Playwrights " +
          "by a given Nationality\n9) Quit" +
          "\n\n Choice: ");
choice = Integer.parseInt(keyboard.nextLine());
while(!isGoodChoice(choice)) //will output if bad choice is made
System.out.print("\nPlease enter the option you wish the program to " +
     "perform.\n\n1) Display all Plays\n2) Display a "+
     "particular Play\n3) Display all plays by a Director\n" +
     "4) Display all Plays of a Cast member\n5) Quit" +
     "\n\n Choice: ");
switch(choice) //switch for which choice the user makes
case 1: addPlay(anES);
break;
case 2: addPlaywright(anES);
break;
case 3: removePlay(anES);
break;
case 4: removePlaywright(anES);
break;
case 5: displayPlays(anES);
break;
case 6: displayPlaywrights(anES);
break;
case 7: displayAPlaywright(anES);
break;
case 8: displayByNation(anES);
break;
case 9: done = true;
break;
public static boolean isGoodChoice(int choice)
return(choice == 1 || choice == 2 || choice == 3 || choice == 4
          || choice == 5);
public static void addPlay(ElementSet anES)
int addRes;
Play2 aPlay = new Play2();
aPlay.readIn(); //Polymorphism
addRes = anES.add(aPlay);
if(addRes == 0)
System.out.print("Could not add. Set is Full.\n");
else if(addRes == -1)
System.out.print("Could not add. Duplicate.\n");
else
System.out.print("Successful add.\n");
public static void addPlaywright(ElementSet anES)
int addRes;
Playwright aPW = new Playwright();
aPW.readIn(); //Polymorphism
addRes = anES.add(aPW);
if(addRes == 0)
System.out.print("Could not add. Set is Full.\n");
else if(addRes == -1)
System.out.print("Could not add. Duplicate.\n");
else
System.out.print("Successful add.\n");
public static void removePlay(ElementSet anES)
String toRemove;
boolean removed;
System.out.print("What play do you want to remove? ");
toRemove = keyboard.nextLine().toUpperCase();
Play2 aPlay = new Play2();
               aPlay = toRemove;
removed = remove(aPlay);
if(removed == false)
System.out.print("Failed to remove.\n");
else
System.out.print("Successfully removed.\n");
public static void removePlaywright(ElementSet anES)
String toRemove;
boolean removed;
System.out.print("What play do you want to remove? ");
toRemove = keyboard.nextLine().toUpperCase();
Playwright aPW = new Playwright(toRemove);
removed = remove(aPW);
if(removed == false)
System.out.print("Failed to remove.\n");
else
System.out.print("Successfully removed.\n");
public static void displayPlays(ElementSet anES)
     String classId;
     System.out.print("Here are all of the Plays\n");
     for (int i = 0; i < anES.size(); i++)
          anE = anES.getCurrent();
          classId = anE.getClassName();
          if (classId.equals("Play2"))
               aPlay = (Play2) anE;
               aPlay.display();
     public static void displayPlaywrights(ElementSet anES)
     String classId;
     System.out.print("Here are all of the Playwrights\n");
     for (int i = 0; i < anES.size(); i++)
          anE = anES.getCurrent();
          classId = anE.getClassName();
          if (classId.equals("Playwright"))
               aPW = (Playwright) anE;
               aPW.display();
public static void displayAPlaywright(ElementSet anES)
     Playwright aPW;
     String wTW;      
     String classId;
     System.out.print("Enter the Playwright you want to search for: \n");
     wTW = keyboard.nextLine().toUpperCase();
     for (int i = 0; i < anES.size(); i++)
     anE = anES.getCurrent();
     classId = anE.getClassName();
     Playwright aPW = (Playwright) anE;      
if (classId.equals("Playwright"))
     if (aPW.equals(wTW))
                              aPW = (Playwright) anE;
     aPW.display();
public static void displayByNation(ElementSet anES)
     Playwright aPW;
     String wTW;      
     String classId;
     System.out.print("Enter the Playwright's Nationality you " +
     "want to search for: \n");
     wTW = keyboard.nextLine().toUpperCase();
     for (int i = 0; i < anES.size(); i++)
     anE = anES.getCurrent();
     classId = anE.getClassName();
     aPW = (Playwright) anE;      
     if (classId.equals("Playwright"))
          if (aPW.getNation().equals(wTW))
                              aPW = (Playwright) anE;
          aPW.display();
} //End Program
I just cannot see where some of my issues are at.

Same program, but different issue. The previous issue was fixed. This issue is in my ElementSet Class.
I cannot see why it cannot find the symbol.
Issue is in the public Element getCurrent() method
Complier:
ElementSet.java:156: cannot find symbol
symbol : constructor Playwright(Playwright)
location: class Playwright
                    return new Playwright((Playwright) theList[saveIndex].clone());
The ElementSet where the issue is:
  public class ElementSet
   // Fields ...
      Element[] theList;      // Will reference an array of objects
                              // from the subclasses of the abstract
                                                // class, Element
      int currentIndex;       // Index of current element in the set
      int currentSize;        // Number of objects currently in the list
      final int MAXSETSIZE = 100;
                        // Maximum number of objects that can be
                                      // in an ElementSet.
   // Constructor ...
      The ElementSet constructor sets up an array with MAXSETSIZE-many
        cells to reference objects from the subclasses of Element.
        It also initializes currentIndex and currentSize.
       public ElementSet()
         theList = new Element[MAXSETSIZE];
         currentIndex = -1;
         currentSize = 0;
   // Test methods
      The isMemberOf method tests to see if the parameter, anElement,
        is already a member of the ElementSet.  Note that anElement can
        reference either a Person, a Student, or any subclass (direct
        or indirect) of the Element class.
         @param anElement the object being checked for membership in
               the set
        @return true if anElement is already in the set and false
       public boolean isMemberOf(Element anElement)
         // Local data ...
         String paramClass = anElement.getClassName();
         String currClass;
           // Logic ...
         for (int i = 0; i < currentSize; i++)
            currClass = theList.getClassName();
     // Only compare anElement against those objects
     // that belong to anElement's class
if (currClass.equals(paramClass))
if (theList[i].equals(anElement))
return true;
     // This object was not found in the set
return false;
The isFull method returns true if the calling object
     is full and false otherwise.
     @return true if the calling object is full to capacity and
     false otherwise.
public boolean isFull()
return currentSize == MAXSETSIZE;
The isEmpty method returns true if the calling object
     is empty and false otherwise.
     @return true if the calling object is empty and false
     otherwise.
public boolean isEmpty()
return currentSize == 0;
// Access methods
The size method returns the number of objects
     currently in the set.
     @return the value of currentSize
public int size()
return currentSize;
The getCurrent() method returns a reference to the
     current object in the set. Note the pre-condition.
     This method should only be called if the set is
     not empty. The method advances currentIndex to
     the next object to set up for the next call to
     getCurrent. If getCurrent returns a copy of
     the last object, currentIndex is reset to 0.
     Pre: currentIndex is not -1 (which can only
     occur if currentSize is not 0).
     @return copy of the current object
public Element getCurrent()
// Local data ...
int saveIndex = currentIndex;
               String classId;
     // Logic ...
if (currentIndex == currentSize - 1)
// Recycle to beginning of list
currentIndex = 0;
else
// Advance currentIndex to next object
currentIndex++;
     // Return a reference to the current object
          classId = theList[saveIndex].getClassName();
               if(classId.equals("Play2"))
                    return new Play2((Play2) theList[saveIndex].clone());
               else
                    return new Playwright((Playwright) theList[saveIndex].clone());
// Mutator methods ...
The add method adds a reference to the parameter object
     to the set if the the set is not full and if the
     parameter object is not already in the set. The
     method returns 1 if the add was successful, 0 if
     the set is full and -1 if the object is already
     in the set.
     @param anElement the object we will try to add
     @return 1 for success, 0 for no more room, and
     -1 for duplicate object
public int add(Element anElement)
// Logic ...
if (currentSize == MAXSETSIZE)
return 0; // set is full
else if (this.isMemberOf(anElement))
return -1; // it's already in there
// We will add anObject to the set.
theList[currentSize] = anElement.clone();
// Increment currentSize.
currentSize++;
// Set currentIndex to object we just added if it was the
// first object in the set.
if (currentSize == 1) currentIndex = 0;
// We succeeded.
return 1;
The clear method resets the set to the empty set.
public void clear()
          for(int i=0; i < currentSize; i++)
                    theList[i] = null;
               currentIndex = -1;
currentSize = 0;
// The display method
The display method displays all of the objects in the
     set using polymorphism in a powerful way.
public void display()
if (currentSize == 0)
System.out.println("There are no objects in the set. ");
else
System.out.println("Here are the objects in the set: \n");
for (int i = 0; i < currentSize; i++)
theList[i].display();
System.out.println("\n");
          //The remove() method will remove a select object.
          public boolean remove(Element anElement)
               for(int i = 0; i <currentSize; i++)
                    if(theList[i].equals(anElement));
                         for(int x = i; x < currentSize; x++)
                              theList[x] = theList[x+1];
                         currentSize--;
                         return true;
               return false;

Similar Messages

  • [svn] 3216: Fix for MXMLG-228, a visibility problem with graphic elements.

    Revision: 3216
    Author: [email protected]
    Date: 2008-09-15 18:13:11 -0700 (Mon, 15 Sep 2008)
    Log Message:
    Fix for MXMLG-228, a visibility problem with graphic elements. This is a quick fix that may force extra display objects when toggling visibility. We should investigate alternate solutions if performance is a problem.
    Bugs: MXMLG-228
    Reviewer: Deepa
    QA: Please check for performance problems when toggling visibility of a large number of graphic elements.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/MXMLG-228
    http://bugs.adobe.com/jira/browse/MXMLG-228
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/GraphicElement .as

    Hello Antonio;
    After many, many test I discovered that the problem, at least in my case it is caused by the new ACR 4.5. Please read the Thread that I post under Camera Raw. I include the link below.
    I also open two Bug Reports about this, but as usual Adobe (and other Software Companies) will never take responsability for this, until one day they release a new version with "enhancements".
    PSE6 Organizer Crash with ACR 4.5 (Vista Only?)
    http://www.adobeforums.com/webx/.3bb6a869.59b60d3e

  • Problem with installing Elements - from noob

    I have problems with installing Elements, it gives my an unknown mistake - I already have CS4 up and running, could this be the case?

    Chances are not very good that pse 4 will run on os x 10 6.8 unless you were upgrading from an earlier mac version that already had pse 4 installed.
    as per this:
    http://forums.adobe.com/message/4474236#4474236

  • Problem with Photoshop Elements Printing

    I have been using Photoshop Elements for a couple of years now and know it pretty well.  Today while attempting to print, a strange problem came up:  After going through the protocol to make a print, just before the image prints PE does a very fast auto correction that basically ruins all the color correction I have made on the image.  How do I disable this function?

    Hi and thanks for your reply. I checked the settings under "Print", "More Options", then "Color Management" and it only has "Print Space", none of the three options that you said I should have.  Am I looking in the wrong place?
    Date: Mon, 3 Sep 2012 11:14:57 -0600
    From: [email protected]
    To: [email protected]
    Subject: Problem with Photoshop Elements Printing
        Re: Problem with Photoshop Elements Printing
        created by 99jon in Photoshop Elements - View the full discussion
      Check your color management by clicking More Options in the print dialog There are basically three options:1) Printer Manages Color2) Elements Manages color3) No color Management Make sure everything is consistent e.g. if you choose Elements manages color make sure color management is switched off in the print driver. 
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4669848#4669848
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4669848#4669848. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Y have problems with Photoshop Elements 12  Bug after reinstallation complet  Impossible working ??

    Morning !
    We have many problems with PHOTOSHOP ELEMENTS 12 ?
    After installation on MAC OS X   YOSEMITE  .
    S O S !!

    Exporter vers photoshop do you receive any specific error messages?  In what way is Photoshop Elements 12 not working?

  • Problems with Photoshop Elements 11

    I have a problem with Photoshop Elements 11, which i bought last week. Installing was completed according the instructions. When I started to use the program my one year old HP-computer with Windows 8.1 informed that there a failure in the Photoshop program and the did not open.

    attach a screenshot of the error message.

  • Problem with database schema objects in the entity object wizard

    Hi All,
    When creating a new entity object, I am facing a problem with database schema objects in the entity object wizard, database schema objects (check boxes for tables,synonyms...) are disabled. Actually I am using a synonym but I am not able to select the synonym check box.
    Can any of you folks tell me how to enable the database schema objects (check boxes for tables,synonyms...).
    Thanks in Advance.
    Raja.M

    Make sure your using rite version of jdeveloper..
    Make sure your using apps schema and check whether your able perform DML operations in the schema vis sql developer.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                           

  • Facing lot of problems with the DATA object  -- Urgent

    Hi,
    I am facing lot of problems with the data object in VC.
    1. I created the RFC initially and then imported the data object in to VC. Later i did some modifications to RFC Function module,and when i reload the data object, I am not able to see the new changes done to RFC in VC.
    2. Even if i delete the function module, after redeploying the IVIew, results are getting displayed.
    3. How stable is the VC?
      I restarted the sql server and portal connection to R3 is also made afresh.... still i am viewing such surprise results..
    please let me know what might be the problem.

    Hi Lior,
    Are u aware of this problem.
    If yes, please let me know...
    Thanks,
    Manjunatha.T.S

  • Problem with premiere elements 4.0

    i am having
    problem
    with premiere elements 4.0. it keeps on crashing and when i put pictures on the timeline it comes up black. when i try to preview it either it shows black or sometimes the picture but i cant see it to delete if i wanted to. also it gave me a message something like that adbe is running low on memory and i should be caution

    This is aimed at Premiere Pro, but may help
    Work through all of the steps (ideas) listed at http://ppro.wikia.com/wiki/Troubleshooting
    If your problem isn't fixed after you follow all of the steps, report back with ALL OF THE DETAILS asked for in the FINALLY section, the questions at the end of the troubleshooting link... most especially the codec used... see Question 1

  • Problem with Copied Business Object : SELFITEM

    Hi,
    sub:    Problem with Copied Business Object : SELFITEM
    I want to use changed selfitem BOR for carbon copy functionality. For it, i copied the BOR : SELFITEM. it is giving error
    In SWI2_DIAG it is showing like this.
    Work item  cannot be read                                                
    Work item 000000639770: Object  method SWW_BI_EXECUTE_S cannot be executed
    The problem is with COPYING The Business Object. Because , generally we extend BOR ,not copy. But i did copy.
    Please help me regarding this.
    Balaji.T.

    hi Martin,
    The problem may not be in method. because simply we copied the BO:SELFITEM into ZSELF . And i want to test this for a mail at first , whether copied BOR  is working or not.The mail is not triggering . it is saying that it is Error.
    WF_BATCH error...
    I can see error in Tx: SWI2_DIAG ,
    this is Error :
    Work item 000000639770: Object  method SWW_BI_EXECUTE_S cannot be executed
    Once it is rectified i can modify the method in BO:ZSELF.
    Thank you in Advance..
    Balaji.T.

  • JDeveloper Extension Problem with Navigator Elements

    Hi,
    I have a problem with the elements of the JDev Navigator.
    At IDE startup I want to set an overlay for the elements on the active project.
    This function is implemented in the Subversion Extension too.
    How can I access the elements of an active project in the navigator?
    It is not a problem to set an overlay with the ContextMenuListener.
    Thank you for your help.
    Greetings,
    Benjamin Oelenberg

    Please take a look at the Extension SDK sample projects. There is a sample that does exactly this.
    Install the Extension SDK from the Help --> Check for Updates dialog and after restart, say yes to installing the sample projects.

  • I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, howev

    I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, however the arrows will move it OK.  Also I cannot drag the selection to another photo in the photo bin as before.

    Hi,
    Please refer: http://helpx.adobe.com/photoshop-elements/kb/pse-stops-responding-yosemite.html
    Thanks,
    Anwesha

  • Problems with ps elements 10 on imac

    hi,
    i just downloaded the programm yesterday from the app store onto my imac. i want to use it as an extention to my aperture 3.
    I have the following questions/problems:
    + starting the programm takes at least 2 minutes, is this normal? I use an Imac Quadcore I7 with 12 gb onboard
    + the preferences: i can only extend the used memory up to 3gb, although i have 12 gb on board?
    + I can not store the preferences, when I shut the programm down, it tells me I do not have the legitimation to store the preferences?!
    + panorama foto work is mostly running out of memory?! 12gb on board
    Please can anybody help me?
    Thanks
    mikle

    No, it does not work on the other account. Problem is still/again the same. In the new account it works perfekt.
    Von meinem iPad gesendet
    Am 08.01.2012 um 22:16 schrieb "Barbara B." <[email protected]>:
    Re: problems with ps elements 10 on imac
    created by Barbara B. in Photoshop Elements - View the full discussion
    If it works in the new account it should hopefully work in your other account, so just log out of that one and go back to the old one and see if it does.
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4125222#4125222
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4125222#4125222. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Photoshop Elements by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Problem with align element.

    Hi everybody,
    i have a problem with align element on my page. I explain:
    i have used into a panel page a panel group to align my element horizontal, but when i set the vertical-align on top, the element are align in middle.
    Now is......
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text tablelayout
    text text text text text text
    text text text text text text
    text text text text text text
    But i wont........
    text text text text text text tablelayout
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    text text text text text text
    Thanks.

    Have you tried using a panelHorizontal instead of a panelGroup?
    The components are automatically laid out horizontally and it has a Valign property that you can set to top.

  • Problems with Premiere Elements 8 after updating to Nvidia driver 195.81 or later?

    Hello PRE8 users,
    If you have an Nvidia-based graphics chipset, and you've updated to Nvidia driver version 195.81 or later and you're still experiencing frequent crashes and freezes in Premiere Elements 8, then we'd like to hear from you in this thread. As mentioned in the announcement at the top of this forum, we believe most of these issues are caused by a problem with an Nvidia driver that was released after PRE8 was developed, and that the issues should be resolved by updating to Nvidia driver version 195.81 or later. Notes from the announcement I mentioned above are copied below for your reference.
    Best regards,
    Chad
    For Nvidia users, there is a driver update that will fix both of the following issues:
    Premiere Elements 8 does not restart after closing on Windows
    Frequent and inexplicable crashes with Premiere Elements 8
    To resolve these issues, you should update your GPU (graphics card) driver to version 195.81 or higher, by following the steps below.
    1.      Identify which GPU driver you have by right clicking on the Desktop > Properties > Settings and in the Display field it will be displayed.
    2.      Go to http://www.nvidia.com/Download/index.aspx?lang=en-us and download driver for your GPU card. Its size varies from 80 to 120MB depending upon the GPU card model.
    3.      After the download is complete, run the driver install Installation. This should take less than 2 minutes.
    There are no known issues that the latest driver update will cause.
    This is an announcement. There is a separate discussion topic located here.
    ***If the update steps shown above do not upgrade your system to version 195.81 or higher, then you may need to download the driver directly. Use the link below only if the steps above do not update your driver to 195.81 or higher. The download page for Vista and Windows 7 is located here:
    http://www.nvidia.com/object/win7_winvista_32bit_195.81_beta.html
    http://www.nvidia.com/object/win7_winvista_64bit_195.81_beta.html

    Processor
    AMD Athlon(tm) II X4 620 Processor
    7.1
    4.9
      Determined by lowest subscore
    Memory (RAM)
    4.00 GB
    7.1
    Graphics
    NVIDIA GeForce 9500 GT
    4.9
    Gaming graphics
    2431 MB Total available graphics memory
    6.3
    Primary hard disk
    231GB Free (466GB Total)
    5.9
    Up here I copied and posted my PC's spec's.  Since upgrading to the new driver, my problems increased.  I seem to experience more crashes than before.  Happens randomly and I can not see a pattern.   (I have noticed dragging clips from one area to another on the time line is no-no)
    JPR

Maybe you are looking for

  • [solved] TeXlive 2009 texexec doesn't work

    I did a fresh install of TeXlive 2009 via pacman (texlive-most). When I try to run texexec I get this message: $ texexec testfile.tex MTXrun | kpse fallback with progname 'context' initialized in 0.03 seconds Have I missed anything in post-install co

  • Change the profit centre in the cost centre master after a year

    Hi All, Could you'll please let me know whether it was possible to change the profit centre in the cost centre master and if i did what will be the implications. Thanks and Regards, Vandana

  • ISE CWA Wireless FQDN resolution

    I can't get my head round how the URL redirect works based on resolving the name in the certificate. Going off my basic diagram I have an ISE (10.1.1.100) with an identity certificate of CN=ise.company.local.  According to Cisco documentation and som

  • How to map Lubricant reclamation process

    We use Refurbishment Order for Repair of Spare Parts. But we have a scenerio where Used lubricant is reclaimed. During this process the volume reduces drastically. How this can be mapped in SAP? Whether this goes out of maintenance and enters product

  • Quick tip help. How to add to vector layers using shape tool

    This is something that's bugged me for a few versions and I'm sure someone has a tip for this. When I use Shape Layer tool, I get a solid color with a vector mask. The tool always makes a new layer every time I use the tool. So to get around that, I