Inheritance problem first part compiles, but can't get the rest to compile.

Here is the assignment :Lab #8, Objects, Inheritance and Polymorphism
Purpose of Lab: Be able to:
Write a Java program that defines, loads, and uses an array of objects.
Create objects of classes.
Understand the notion of polymorphism.
Write superclasses and subclasses.
Create objects of superclasses and subclasses.
Instructions:
1. Write an Abstract Data Type called Animal. Include two instance variables in this class: a String for name and an integer for age. Write a constructor method that takes two arguments and a second constructor that takes no arguments. Write get and set methods for each of the two instance variables. Write a toString method which displays the values of the instance variables for any object of type Animal. Write a speak method that takes no arguments, returns nothing and displays ?Arg! Arg!? on the monitor.
2. Write a second class called Duck, a subclass of class Animal. Add an additional instance variable to those inherited from Animal: an integer called feathers (this variable is used to store the number of feathers that a particular Duck object has). Write a constructor that takes three arguments and another constructor that takes no arguments. Provide set and get methods for the feathers instance variable. Override the toString method to display the values of all instance variables belonging to a Duck type of object. Override the speak method to display a value of ?Quack! Quack!?.
3. Write a third class called Cow, also a subclass of class Animal. Add an additional instance variable to those inherited from Animal: an integer called spots (this variable is used to store the number of spots feathers that a particular Cow object has). Write a constructor that takes three arguments and another constructor that takes no arguments. Override the toString method to display the values of all instance variables belonging to a Cow type of object. Override the speak method to display a value of ?Mooo! Mooo!?.
4. Finally, enter, compile and execute the Farm class shown below. Make sure that all of your classes (Animal, Duck, Cow and Farm) are in the same folder. Compile all of the classes. Run the Farm program. Answer the questions below. Here is my code so far: public class Animals{
    private String name;
    private int age;
    public Animals()
    public Animals( String nVal, int ageVal)
        name =nVal;
        age = ageVal;
    public void setN(String nVal)
        name = nVal;
    public String getN()
return name;
public void setA( int ageVal)
age = ageVal;
public int getA()
    return age;
public String toString()
    return "\nThe name is" + name +", and the age is" + age + ".";
public class Duck extends Animals
private int feathers;
public Duck()
    super();
    public Duck(String nVal, int ageVal)
    super(nVal,ageVal);
    feathers = feathersVal;
    public void setFeathers(int feathersVal)
    feathers= feathersVal;
    public int getFeathers()
        return feathers;
    public String toString()
    return  "\nThe name is" + super.getN() + ", and the age is" + super.getA()
    + "\n The Duck's feathers are" +feathers+ ".";
public class Cow extends Animals
    private int spots;
    public Cow(int spots)
        super();
        public Cow(String nVal, int spotsVal)
        super(spots);
            spotsColor = spots;
            public void setSpots(int spots)
        spots= spotsColor;
            public int getSpots();
    public String toString()
        return  "\nThe name is" +super.getN()+ ", and the age is" + super.getA()
        + "\n The Duck's feathers are" +feathers+ "\nThe Cow's spots are" +spots+".";
import javax.swing.JOptionPane.JOption;
import javax.swing.*;
public class Farm
    public static void main( String[] args );
    Animals[]farmAnimals = new Animals[4];
            farmAnimals[0] = new Animals("Animals", 3);
            farmAnimals[1] = new Duck("Duck","green,grey feathers");
            farmAnimals[2] = new Cow("Cow", 3, "brown white spots");any help greatly appreciated last assignment of the semester!

Here is the assignment :Lab #8, Objects, Inheritance and Polymorphism
Purpose of Lab: Be able to:
Write a Java program that defines, loads, and uses an array of objects.
Create objects of classes.
Understand the notion of polymorphism.
Write superclasses and subclasses.
Create objects of superclasses and subclasses.
Instructions:
1. Write an Abstract Data Type called Animal. Include two instance variables in this class: a String for name and an integer for age. Write a constructor method that takes two arguments and a second constructor that takes no arguments. Write get and set methods for each of the two instance variables. Write a toString method which displays the values of the instance variables for any object of type Animal. Write a speak method that takes no arguments, returns nothing and displays ?Arg! Arg!? on the monitor.
2. Write a second class called Duck, a subclass of class Animal. Add an additional instance variable to those inherited from Animal: an integer called feathers (this variable is used to store the number of feathers that a particular Duck object has). Write a constructor that takes three arguments and another constructor that takes no arguments. Provide set and get methods for the feathers instance variable. Override the toString method to display the values of all instance variables belonging to a Duck type of object. Override the speak method to display a value of ?Quack! Quack!?.
3. Write a third class called Cow, also a subclass of class Animal. Add an additional instance variable to those inherited from Animal: an integer called spots (this variable is used to store the number of spots feathers that a particular Cow object has). Write a constructor that takes three arguments and another constructor that takes no arguments. Override the toString method to display the values of all instance variables belonging to a Cow type of object. Override the speak method to display a value of ?Mooo! Mooo!?.
4. Finally, enter, compile and execute the Farm class shown below. Make sure that all of your classes (Animal, Duck, Cow and Farm) are in the same folder. Compile all of the classes. Run the Farm program. Answer the questions below. Here is my code so far:
public class Animals{
private String name;
private int age;
public Animals()
public Animals( String nVal, int ageVal) }
name =nVal;
age = ageVal;
public void setN(String nVal)
name = nVal;
public String getN()
return name;
public void setA( int ageVal)
age = ageVal;
public int getA()
return age;
public String toString()
return "\nThe name is"+name+ , and the age is" + age + ".";
{code}{code}
{code}{code}
public class Duck extends Animals
private int feathers;
public Duck()
super();
public Duck(String nVal, int ageVal)
super(nVal,ageVal);
feathers = feathersVal;
public void setFeathers(int feathersVal)
feathers= feathersVal;
public int getFeathers()
return feathers;
public String toString()
return "\nThe name is" + super.getN() + ", and the age is" + super.getA()
+ "\n The Duck's feathers are" +feathers+ ".";
{code}{code}
{code}{code}
public class Cow extends Animals
private int spots;
public Cow(int spots)
super();
public Cow(String nVal, int spotsVal)
super(spots);
spotsColor = spots;
public void setSpots(int spots)
spots= spotsColor;
public int getSpots();
public String toString()
return "string1" + variable1 + "string2" + variable2;
{code}{code}
{code}{code}
import javax.swing.JOptionPane.JOption;
import javax.swing.*;
public class Farm
public static void main( String[] args ){
Animals[]farmAnimals = new Animals[4];
farmAnimals[0] = new Animals("Animals", 3);
farmAnimals[1] = new Duck("Duck","green,grey feathers");
farmAnimals[2] = new Cow("Cow", 3, "brown white spots");
{code}{code}
In Duck The compile errors are as follows:java1: cannot find symbol symbol class Duck extends Animals with the caret under A in Animals
java 13 same as above but for feathers = feathersVal; with the caret under f in feathersVal
java 25 same error caret under s in both supers
Cow has 1 error in java 20 class,interface,or enum expected caret under S in String
Farm a parsing error at last brace but when I add another ending brace i get
java1 cannot find symbol class JOption caret under period between JOptionPane.JOption
java 9 cannot find symbol caret under A in Animals[]farm etc also under A in new Animals
java 10 cannot find symbol caret under D in Duck
java 12 cannot find symbol caret under C in new Cow

Similar Messages

  • TS1702 help, are you having the same problem? iPad 2 calendar, can't get the month of March, can get days in March, but not month view. Any suggestions, thank u.

    help, are you having the same problem? iPad 2 calendar, can't get the month of March, can get days in March, but not month view. Any suggestions, thank u.

    Hi melbernai - not sure if you've solved this problem yet. I had the exact same problem recently with my 2nd Gen iPod Nano. I solved it yesterday by simply updating iTunes to the most recent version, after which I could get rid of the register screen. The only other thing I needed to do to add my custom playlists was select "Manually manage music" on the screen for my iPod, since it had been in an automatic synching mode since the problem occurred.

  • I have a photo album in my apple tv but can't get the apple tv to use it as a screen saver. it is using older photos

    I have a photo album in my apple tv but can't get the apple tv to use it as a screen saver. it is using older photos

    Is this a software or hardware issue? 

  • This is a stupid question but I needed to ask because I don't want to go there and not being able to buy it, but can I get the iPhone 5 brought straight there when I go to an apple store?

    This is a stupid question but I needed to ask because I don't want to go there and not being able to buy it, but can I get the iPhone 5 brought straight there when I go to an apple store?

    And I meant go to the apple store physically without preordering it online, and I meant the Southampton one. So could I just stroll in apple store and buy a iPhone 5 in Southampton apple store and buy the iPhone 5 straight away? Because I didn't want to have to wait? I just want to go in and buy it and go out with it, if you guys get what I mean? And felipeV if it is in stock could I just buy it and leave with my iPhone 5?

  • I have downloded ITunes to a new laptop and signed in this let's me download previous purchases in to the librery but can't get the films I have bought quite a lot over time any idea how I can get them ???

    I have downloded ITunes to a new laptop and signed in this let's me download previous purchases in to the librery but can't get the films I have bought quite a lot over time any idea how I can get them ???

    You cannot.
    You buy one and only one download of movies.  it is your responsibility to backup your purchases.
    Copy everything from your old computer or your backup copy of your old computer to your new one.

  • I have my redemption code but can't get the serial number for adobe photoshop elements 12 that I jus

    I'm trying to find out my serial number.  I have the redemption code but can't get the serial number for adobe photoshop elements 12 that I just purchased

    Hi KEsheppard
    Please refer the link below to get the help regarding redemption code and the serial number:
    http://helpx.adobe.com/x-productkb/global/redemption-code-help.html
    Let us know if it helps,
    Thanks!
    Gurleen Kaur

  • I can record and hear me recording through the computer's built in mic, but can't get the external mic and headphones to work., The preferences are set for the external mic and headphones...

    I can record and hear me recording through the computer's built in mic, but can't get the external mic and headphones to work., The preferences are set for the external mic and headphones...

    What operating system are you using? Is it on a Mac or a PC? Which preferences are set for external mic/headphones, Audition's or the computers?

  • I can run a slide show using apple tv and itunes but can't get the slides to run in a specific order

    I can run a slideshow (of pictures) using Apple TV and ITunes but can't get the pictures to run in the order I set them up with in my hard drive directory

    Welcome to the Apple Community.
    Websites and third party Apps need enabling before they will allow AirPlay of Video content. Some Website/App developers have not enabled their products, some simply haven't got around to it yet, others have stated that they won't be enabling AirPlay (likely as a result of licensing issues).
    I have created a User Tip to list Apps that have been tested with Video Airplay, if you have any Apps that you have tested please leave details in the comments at the bottom of the User Tip or email me if you don't have commenting privileges.

  • Hello, trying to download the latest iTunes software version, a pop up comes with a "invalid signature" message. Try to do download only with the same results. I can buy and download from iTunes but can't  get the latest version?

    Hello, trying to download the latest iTunes software version, a pop up comes with a "invalid signature" message. Try to do download only with the same results. I can buy and download from iTunes but can't  get the latest version?

    Transfer Purchases  = iTunes > File > Transfer Purchases
    http://support.apple.com/kb/HT1848

  • I can't seem to get my apps or music on my new iphone.  all my contacts, pics, emails, etc. transferred, but can't get the apps/music

    i can't seem to get my apps or music on my new iphone.  all my contacts, pics, emails, etc. transferred, but can't get the apps/music

    apps and music should be in your itunes media library, sync to itunes to get them back on your phone.

  • Trying to start developing but can't get the compiter set up correctly

    Hey guys, I'm following the starling tutorial step by step (http://tv.adobe.com/watch/starting-with-starling/starting-with-starling-introduction-and-s etup/" but I always keep getting errors no matter what, seems like I just can't get the sources/new libs to work correctly...honestly I don't even know how to get the standard libs working but I have programming experience so I'm familiar with functions and arrays etc.
    Here's what the compiler poops out as of right now, (I have tried to set it up numerous times...)
    Description
    Resource
    Path
    Location
    Type
    Access of possibly undefined property myStarling.
    Main.as
    /Newest Proj/src
    line 17
    Flex Problem
    Access of possibly undefined property myStarling.
    Main.as
    /Newest Proj/src
    line 18
    Flex Problem
    Access of possibly undefined property myStarling.
    Main.as
    /Newest Proj/src
    line 19
    Flex Problem
    Access of possibly undefined property starling.
    Game.as
    /Newest Proj/src
    line 10
    Flex Problem
    Call to a possibly undefined method Starling.
    Main.as
    /Newest Proj/src
    line 17
    Flex Problem
    Call to a possibly undefined method Stats.
    Main.as
    /Newest Proj/src
    line 14
    Flex Problem
    Type was not found or was not a compile-time constant: Event.
    Game.as
    /Newest Proj/src
    line 13
    Flex Problem
    Type was not found or was not a compile-time constant: Starling.
    Main.as
    /Newest Proj/src
    line 10
    Flex Problem
    Type was not found or was not a compile-time constant: Stats.
    Main.as
    /Newest Proj/src
    line 9
    Flex Problem

    What are the paths to the Starling files and what are the compiler options you are using?

  • My LCD screen burned out. I have it connected to a tv now, but can't get the menu bar or the function bars to show up. Please help!

    My LCD Screen burned out, but the computer still works. I currently have it connected to an HDTV via, Mini DVI to VGA, VGA to VGA on the tv. Problem is, I can't get the function bar (maybe not the right term) or the bar at the bottom with all my programs on it. I get my screen saver and have managed to drag (by sheer luck since I can't see anything on my iMac screen) some of my pics I had on my desktop over, but nothing else. Please help!

    Hello
    you should have on your key board "mirroring key" , or F7 on old keyboard
    for now your tv is an extended screen for your imac not a miror , so you can not see menue barre on top of screen
    http://docs.info.apple.com/article.html?path=Mac/10.5/en/8525.html
    HOPE you are in 10.6
    http://docs.info.apple.com/article.html?path=Mac/10.6/en/8525.html
    "On some keyboards, you can press the F7 key, or Command-F1, as a shortcut to turn video mirroring on or off."
    HTH
    Pierre

  • Connected to WiFi but can not get the internet

    I'm really hoping that someone can help. I bought my Ipad yesterday but am unable to connect to the internet. I have connected to my WiFi and have full signal strenght but when I go on Safari it tells me that I'm not connected. I have tried changing some of my settings but can only get as far as the message 'Cannot open page - Safari could not open the page because the server stopped responding' I also have the same problem with my Iphone and Ipod touch, I have never tried to sort these as don't need the internet on them. I have tried updating my Itunes and Ipad, both are now fully updated. My internet is working fine on any computer that is not apple... Please help, im pulling my hair out here.
    Many thanks

    What do you see if you go to Settings > WiFi and touch the ">" next to your network name?
    If you touch the ">" you will get the details of your network connection. Things like the type of IP address allocation (DHCP, Static, Bootp), assigned IP Address, Subnet Mask, Router address, DNS addresses, etc.
    Please report what you see there.
    Also please identify the make, model and type of router you have.
    Do you know what kind of security you are using on your router? None, WEP, WPA, WPA2?
    When you said, "I have tried changing some of my settings", what did you do?

  • I bought an album and one of the songs did not download completely.  It shows that the song is 3:17 seconds but only got 40 secs. of it.  How can i get the rest of the song back?

    I bought an album from itunes and one of the songs did not download completely.  It shows in the player that it is 3:17 but only plays for 40 secs.  How can i get the entire song back?

    I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the entry, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.
    (Not entirely sure what happens after you click that link, but fingers crossed it should be relatively straightforward.)

  • Iphone 5 stollen got a new one but can't get the icloud backup

    My Iphone was stollen and I put on lost mode on "find my Iphone". Now I have a new one and I'm trying to get the backup from icloud, but I always get a message that my Apple ID is locked. I've already reset my password twice and deleted the previous equipment from the app (Find my Iphone), but I still can't get the backup.
    what should I do?? Tks

    For you to get the pictures off the old device, you would need to have connected the device to the computer in the past, so you could select it to trust the devices. Without a working screen on the device you will not be able to do that. Because of that, you would not be able to even use your computer to navigate the file system to get the photos. Since you never created a backup in iTunes, did you do one in iCloud? If not, then the pictures cannot be recovered. Why would you not backup your phone, or import photos to the computer like you would with a digital camera?

Maybe you are looking for

  • "Backup" of iTunes library didn't load everything.

    I'm new to iTunes, so please bear with me.  I'm now running iTunes 11.3 under Windows 7 Home Premium SP1. My son-in-law bought a used PC from a friend some years ago and "inherited" an iTunes installation with hundreds of songs along with it.  He occ

  • Help with collision and layers....

    Hi everyone I'm having a problem with this isometric RPG im making where this little guy walks around in this room with this shelf in it. But when I go in front of the shelf I want it to swap layers and vice versa on the other side so it looks 3D my

  • Sent messages suddenly missing

    So this morning I went back to look at an old message (Dec 2014) in my Sent folder to get some information out of it and it would not open, just showed blank screen. No other issues that have been noted and Sent folder was working last week. I double

  • Where i can find software for NOKIA 3250

    Im from Russia, so please excuse mefor my bad English =)

  • There is a yellow top bar asking me to update programs, I don't know if I should trust it

    The yellow upper bar does not go away. It is asking me to update numerous programs. When I click into it it looks official (as Mozilla page), but I want to be sure it's legit. If not how to I delete it?