Using the Super Word in a tutorial

ive created two classes:
public class Polygon
int sides;
double area;
public Polygon()
System.out.println("Inside no-arg constructor");
public String NumberOfSides()
System.out.println("The Number of Sides = " + sides);
return sides;
public String toString()
System.out.println("Inside Polygon toString")
String rep = "Sides" + sides + "area" + area;
return rep;
public Polygon(int s)
sides = s;
System.out.println("Inside One-Arg Constructor");
public class Triangle extends Polygon
int base;
int height;
public Triangle(int b, int h)
base = b;
height = h;
The tutorial i am using says, 'Add a constructor to Triangle that takes in two int's for base and height. The constructor needs to use super() to invoke the constructor in Polygon, passing in 3 for the number of sides. Print out the message "Inside Triangle Constructor"
as you can see i've created the triangle constructor which takes in the two int's but i am unsure how to use the super keyword to use the constructor within the polygon class to pass in 3 as the number of sides.
can someone help me in solving this problem.
Thanks
Richard.

if i was to change the order to that would it not
take the NumberOfSides() and the toString() methods
out of the no-argument constructor?You cannot put methods inside methods.
That makes no sense in Java.
i deliberately
put them there because i only want them for the
no-arg constructor. or must methods be seperate
entities from constructors?Yes.
And in fact, you have 2 more problems:
your "sides" and "area" variable are uninitialized
if people use your "no-arg" constructor,
so the compiler will complain.
You need to assign them some value in your constructor
(perhaps "slides=0; area=0;")

Similar Messages

  • HT1338 how do i load windows 7 on a mac air using the super drive?

    How do I load windows 7 on a Mac Air using the super drive?

    You use Boot Camp to partition the SSD in the Air, download the Win 7 Support files from Apple (part of the boot camp process), save them to a USB thumb drive, have the USB superdrive connect to the Air with the Win 7 install DVD in the drive. Once partitioned the system will reboot and start the Win 7 install.

  • How do I use the INTO word in my querys?

    Hi! I'm working with Oracle 10g and Microsoft Visual Studio 2008 (Visual C#), I connected both succesfully, now I can add data to my tables from C#, but the problem comes when I try to request data from the database, I'm trying to do that with this query: "SELECT Id_Estado, DetalleEstado FROM Estado", but it doesn't work, it shows me an error, saying that I have to put an "INTO" in my query, but, where should I put it? and in wich kind of "object" should I save the data that I'm requesting.
    I guess I have to make a query like this: "SELECT Id_Estado, DetalleEstado INTO "an object/container" FROM Estado".
    I'm new with Oracle, I hope you can help me. Thank you so much.

    I would suggest you this
    1. Create a stored function with return typer as REF CURSOR. You can create your own REF CURSOR or use the oracle supplied one i.e. SYS_REFCURSOR.
    2. Inside the function do something like this.
    create or replace function get_estado_data return sys_refcursor
    as
      pOutCursor sys_refcursor;
    begin
      open pOutCursor for
      select * from Estado;
      return pOutCursor;
    end;
    /3. Now from your C# call this function using ExicuteDataSet API and store the output in a DataSet.

  • What frustrates you when using the "Administrator Word Bench"? (RSA1)

    Hi All,
    As a developer and user of the "Administrator Workbench (RSA1)" ... what feature makes you mumble under your breath in frustration?
    Problem: When deleting PSA requests, the dialog box does not have a u201CSelect Allu201D button. It was easy to manually clean up the PSA requests in the older AWB.
    Solution: You have several choices, neither of them is ideal and both are not as good as having a u201CSelect Allu201D button. You can either select each row/requests individually or change screens and create a temporary process chain/variant in transaction RSPC to do it.
    Problem: The u201CTransport Connection Wizardu201D functionality is a memory hog that spends a lot of time processing iterative, nested loops which means even a decent hardware capable desktop slows down and makes selecting/ticking individual nodes/objects to be gathered into a transport request a slow and un-necessary time consuming activity.
    Solution: You can stop the slowdown from occurring by collapsing the branches as you go. There is a very noticeable difference in speed if you minimise the number of open branches at any given point in time. This allows you to gather many simular objects in one cycle and then proceed to analyse them all at once by navigating the object tree one branch at a time.
    The question is only for BW Developers and Administrators who spend a fair amount of time in transaction RSA1.
    Please, politely vent your frustration at even the smallest thing.
    Kind Regards,
    John.

    Hi Durgesh,
    Sven is absolutely right.
    You need to put some time aside and remove the unused objects from the system. Usually the development system is the worst as many objects are activated but never used and never transported.
    This activity is best done in reverse to the order in which you would have activated the content.
    Web Templates
    Queries
    MultiProviders
    DTP
    Transformation
    Update Rule
    InfoSource
    Cube
    DataStore
    InfoPackage
    InfoArea
    Application Component
    Etc, etc, etc u2026
    I would suggest a 2 phase approach to doing this.
    (1) The $TMP objects. Try once for all objects that allow you to delete them without a transport request. Take note of the objects that have previously been transported as you would be wise to do further impact analysis in the Test and Production systems before committing to deleting them from Development and transporting the deletion. For each of the previously transported objects do a quick where-used search in the Test and Production systems to confirm that it is truly not being used. The issue we are trying to avoid is that we can never know what other developers might have broken in development (accidentally) without realising and then you come along and transport an object deletion that was ok (not related) in development but is still being used in Test/Production.
    (2) Using the above list of previously transported objects, try transporting the deletion of only 1 type of object per week or per official transport cycle for move to Production. This will allow you to clean up the system with out consuming too much noticeable time from other more important activities. It will also reduce the risk of getting something wrong because boring, monotonous tasks like this one (clean up) it is too easy to get distracted and accidentally transport active objects that you did not mean to.
    Now do a clean up of unused DataSources in any source system connected to BW.
    This includes DataSources for the "Myself" DataMart where BW talks to itself.
    Kind Regards,
    John.

  • Can I get Pages to automatically use the first words of my new document as the title of it, the way Word does?

    This s a very handy feature of Word that I would like to use also in Pages.

    Run this huge script :
    --{code}
    property title_len : 32
    tell application "Pages"
              tell document 1
                        set newName to (characters 1 thru title_len of body text) as text
              end tell
              set name of document 1 to (newName & ".pages")
    end tell
    --{code}
    Yvan KOENIG (VALLAURIS, France) samedi 13 août 2011 19:56:19
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Powershell search for a word and use the next word

    Here is the skinny.  I am trying to easily part through a event log of print jobs.  I export it to a CSV, grab only the events that pertain to what I need but I am stuck there.  Here is a sample of what I need help with.
    Microsoft Word - Test Print owned by user1 on computer1 was printed on printer1 through port
    Obviously document name, user1, computer1 and printer1 will be different in almost every case.  How do I parse through this and grab the username, computer and printer.  I was thinking search for "owned by", but how do I grab the name?
    Thanks for the help.

    ok now I am running into another issue.  Apparently the nuances of splitting by word seems to be los on me.
    when I do
    foreach ($job in $printjob) {        $test = $job.split("owned by")        echo $test}
    It will then split the line by each and ever "o", "w", "n", "e", "d", etc.....  I even tried $test = $job.split("'owned by'").  Any ideas?
    I feel like I should explain why this is happening.
    When you call $job.Split(), you're calling the .NET Split() method of the object System.String.
    If you look at the overloads of split (i.e., all the different ways you can call String.Split) - link here https://msdn.microsoft.com/en-us/library/system.string.split%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 -,
    you'll notice that the only way of calling String.Split() with a single parameter is if you pass a char[], an array of characters.
    Now, if you were coding in C# or VB.NET and you did... String.Split("owned by"), you'd get an error saying that it's expecting a char[] but you gave it a string.
    Powershell however is a bit 'smarter' and it tries to accommodate... It knows that the method expects a char[] and it knows you gave it a string, but it also knows how to convert it to a char[], so it does that, and that's what the method String.Split()
    receives.
    And what happens when the method String.Split() receives a char[]? It splits on every single character in that char[], as you've seen :)
    How to fix it? Well, there are two overloads that accept a string[], so you can use those. Now here's an interesting fact...
    In the same way that PowerShell converted a string to a char[] to accommodate the needs of the method you were calling, it can also convert a string into a string[], so you could do this:
    $job.Split("owned by", [System.StringSplitOptions]::None)
    You're passing it a string... and a [StringSplitOptions] object, so you expect it to call the third overload from the page I provided earlier.
    But if you run it... you still get the same stuff as before! What gives?
    Well, seeing as in this particular case there is an overload that receives char[] and another that receives string[] and you passed a string, which means PowerShell will always have to convert it into something anyway... You have no control
    over what PowerShell will decide to convert the string to. It could convert to char[] or to string[]. In this case, because the definition of the char[] method appears before the string[], that gets picked.
    So, finally... how to force PowerShell to pick the string[] overload? Well, don't give it a choice!
    $job.Split([string[]] "owned by", [System.StringSplitOptions]::None)
    So here I'm casting the string into a string[] before it gets passed to the method, so PowerShell does not need to perform any conversion itself and everything is right with the world.
    Hope this helps :)

  • How do I use the Microsoft word application on iPad

    I have recently bought Microsoft office 2010 on the application store and I  can not figure how to use it for documents,please help

    There is no Microsoft Word for the iPad. You can use 3rd party suites (I use Documents to Go, other popular ones are QuickOffice and Office squared) or the Apple WP app (Pages has an iOS version).

  • Modifying a filename using the first word contained in the document.

    Hi,
    I recovered around 2500 .doc files, lost in a drive fail (I know) and I've been trying to find a way to speed up the renaming process : I'm trying to create a macro that could grab the first characters, or first word of each file and replace Its filename with those characters. In a 2500-docs batch. I tried a lost of things, but am not sure if it's doable with Applescript.
    Help ?
    Thanks.

    There are no bells and whistles here - e.g. minimal error checking - but this should give the basic pattern for applescript. Copy it into the applescript editor, save it as an application, then drag&drop files onto the application.
    on open theFiles
              repeat with thisFile in theFiles
                        set thisPosixFile to POSIX path of thisFile
                        tell application "Microsoft Word"
                                  open thisFile
                                  tell document 1
                                            set wordOne to (get content of first word)
                                            close
                                  end tell
                        end tell
                        tell application "System Events"
                                  try
                                            set ext to name extension of disk item thisPosixFile
                                            set name of disk item thisPosixFile to wordOne & "." & ext
                                  on error errstr
                                            display dialog errstr
                                  end try
                        end tell
              end repeat
    end open

  • I hate to use the virus word but I can't explain....

    I have random new message windows pop up filled with words.  and new tabs will open in safari to a site like bing or yahoo with the same gibberish typed in
    I'm not new to macs and most of my reading consumion is Apple/Mac articles, so I haven't seen anything about a virus or such....I'm just at a loss
    Here are some screen shots.....
    another scary part is some of the gibberish on the emails includes phrases that look like they were lifted off other email....help!
    Thanks,
    Todd

    You have Dragon installed.  This has become a common complaint here recently.  I don't have Dragon, so I don't know what it's doing, but I suspect there's a setting that allows some audio cue to tell it to start dictation, and it thinks it has heard that cue.  That could be totally off-base, but that doesn't change where the blame lies! 

  • Using the Pages word processor

    How do I copy a document from e mail to pages?

    If the 'document' is an email message, select all of the message, Copy, open a blank Pages document, Paste.
    If the 'document' is an attached file in a format that Pages can open, drag the document's icon from the message onto the Pages icon in the Dock.
    Other methods are possible, some depending on what the 'document' actually is.
    Regards,
    Barry

  • Can't Get the "Compare Word Documents" Automator Action to Work

    I'm trying to build an automator workflow that will use the "Compare Word Documents" action (office 2011) to compare 2 documents.  The expected output would be a new document that shows the changes made between document A and document B, much as if I had used the "compare documents" feature within word.
    I think I must be passing the wrong variables into this action because I cannot get the compare to actually work.  Here's what I've tried:
    I have a "get specified finder item" that selects document A
    Then I have an "open word document"
    Then I have a "compare word documents".  In the "Compare Against", I have selected document B
    When I run this workflow, I end up with 4 windows open -- document A, document B, a copy of each.  And in no case do I see the comparison.
    Does anyone know how to get the compare documents workflow to work properly?

    Hi Bob,
    That is what I thought...but, then when I learned about the End Nested Style Sheet here character, I thought that would override that issue.
    Thanks for clarifying that there is no way around the new paragraph issue.
    I kept thinking there has to be a way and I just don't know how to do it, but I guess that is not the case. That is the only downfall to me regarding that amazing feature.
    thanks!
    Barbara

  • How do I synchronize display with printed colors using the Calibration Syst

    The windows headed "Determine your display's native response..." seem confusing to me in the use of "match" and "neutral" matching of the backgrounds using the apple shape and adjacent sliders.
    I have accumulated several settings and may have tampered with the original one which I would like to go back to.
    The printer is a Canon iP6000 and produces great pictures off my Win XP machine whose native calibration I never had to change. Thanks for any help.

    Thanks for the feedback. Some people (tech writers, in this instance) think that being clear and concise, even if you have to use the same word more than oncd, isn't creative, modern, or cool enough. They've fallen for looking good and forgot about being good. Good computing.

  • Even more about deleting the first word in a string

    hi, i have this code that removes the first word in a string, returns the shorter string, removes the first word from the shorter string aso... what i would like it to do is to stop when it hits a non-character, but i can't get it to do that. does anyone know why \b won't work?
    import java.io.*;
    class Testar {
    public static void main(String[] args) {
          String partDesc = "Hi my name is SandraPandra.";
          while (partDesc.equals("\b") == false) {  //this is where something goes wrong
              System.out.println(partDesc);
              partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
    } thanx in advance!

      while (partDesc.equals("\b") == false) That compares partDesc to a string consisting of one backspace character. I suspect you're trying to use the regex word-boundary anchor, but that's a dead end. If you want to stop beheading the string when the regex stops matching, you can write the code exactly that way: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        while ( partDesc.matches("^(\\w+)\\s+.*") ) {
          partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
          System.out.println(partDesc);
    } If performance is a concern, you can use a pre-compiled Pattern object for greater efficiency. Thanks to Matcher's lookingAt() method, you can use the same regex for the test and the replacement: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        Pattern p = Pattern p = Pattern.compile("^(\\w+)\\s+");
        Matcher m = p.matcher(partDesc);
        while ( m.lookingAt() ) {
          partDesc = m.replaceFirst("");
          System.out.println(partDesc);
          m.reset(partDesc);
    } The ^ anchor isn't really necessary in this version, since lookingAt() implicitly anchors the match to the beginning of the string, but you might as well leave it in.

  • MBP suddenly shuts down when using the superdriveP shuts down when u

    Randomly my husband:s MBP shuts down when using the super drive. What could be the cause of this?
    Appreciatte your Help

    Yeah, I hope it is just a firmware-problem. AND that Nokia will release an update soon. The version on my phone now is 021.013, and it is from July. A firmware update is long overdue now, especially after all the other problems reported with this phone. And btw I have turned the phone on and off several times without this helping to fix the radio-issue...
    I guess I will have to return the phone soon, if Nokia is unable to release a fixed firmware.

  • Using the word super to access superclass fields - How?

    I just read that it is possible to access public members of the superclass by using the keyword super. To test it, I tried the following but it does not work. What is the proper way?
    public class A {
         public String color = "Black";     
    public class B extends A{
         public String color = "White";
    public class test {
         public static void main(String[] args) {
              A x= new A();
              B y= new B();
              System.out.println(x.color); //returns Black
              System.out.println(y.color); //returns White
              System.out.println(y.super.color); ERROR!!!
    }

    Just trying to make this readable
    package forums;
    class Superclass {
      public String name = "Superclass";
    class Subclass extends Superclass {
      public String name = "Subclass";
    public class TheSuperSubClassTesterator {
      public static void main(String[] args) {
        Superclass superclass = new Superclass();
        System.out.println(superclass.name); //returns Superclass
        Subclass subclass = new Subclass();
        System.out.println(subclass.name);  //returns Subclass
        System.out.println(subclass.super.name); //ERROR!!!
    compile
    ---------- build ----------
    C:\Java\home\src\krc\tools>"C:\Program Files\Java\jdk1.6.0_12\bin\javac.exe" -Xlint -d C:\Java\home\classes -cp c:\java\home\src;.;C:\Java\home\classes C:\Java\home\src\krc\tools\TheSuperSubClassTesterator.java
    C:\Java\home\src\krc\tools\TheSuperSubClassTesterator.java:20: cannot find symbol
    symbol  : class subclass
    location: class forums.TheSuperSubClassTesterator
        System.out.println(subclass.super.name); //ERROR!!!
                           ^
    1 error
    Output completed (1 sec consumed)

Maybe you are looking for

  • Payslip(HR Forms) is not getting displayed

    Experts, We are using HR forms for pay slip, i am not able to display/print form for one of the employee. How to solve it/ Pls advice. Also if we deleted any wage types which has paid in the past run, system is doing retro and getting stored in RTs.

  • Adobe Reader for Ipad 1

    Hi Everyone, I would like to complete a file on my Ipad 1. This file is a pdf only supported by Adobe Reader. The file (about 969 k) is suported in my computer whithout any problem, but I can't open it on the Ipad, even if I get the latest version of

  • Instructing clients on domain name transfer

    I was wondering what the easiest way is to instruct a client how to transfer their domain name from a previous host to a new one. Do you simply give them the information fom the "Whois" lookup? Do you contact the previous host yourself? What do you d

  • TRUNCATE PROBLEM

    HI FRIENDS, CAN ANY ONE TELL , FROM WHICH FUNCTI0N MODULE WE CAN TRUNCATE . INPUT      - > ABCDEFGH OUTPUT   - > ABCDE IT'S URGENT, PLZ. HELP ME

  • Question in creating view pages

    Hi, I'm pretty new in SharePoint 2010 and I'm trying to design a simple task list in a tabular format. Below is the link to my screenshots https://plus.google.com/photos/111135350719234396436/albums/5969419655213868465?authkey=CK-WxOzIqP3F8wE When I