Advanced OO


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Advanced OO

  1. #1
    Join Date
    Aug 2008
    Posts
    1

    Advanced OO

    Hullo,
    Please members assist me with this task i have tried for one week but am not getting the solution. Am new in programming am just trying to learn the language.


    Question


    1. Create an interface called limb and modify your arm and leg classes so that they implement it.
    2. Create a new abstract class called Mammal and move any properties and methods that all mammals have from your Human to the Mammal class.
    3. Ensure that your mammal has a private property which is an collection of limbs and protected methods to add, remove and retrieve the limbs (alternative solution would be to have protected collection of limbs and protected constructor in which you can pass collection of limbs to add).
    4. Modify your Human to extend Mammal.
    5. Add methods to your Human that return collections of arms and legs. implement these methods by iterating through the collection of limbs and checking what type of limb they are. Note that you will need to use the instanceOf keyword but we haven't covered it so you will need to research it.
    6. Create three new classes that represent pets. They should all be mammals but have some unique characteristics.
    7. Create a Family class that creates two humans (yourself and your ideal partner) and three pets.
    8. Extend the Human class to create two new classes Adult and Child.
    9. Make sure your human has an age property.
    10. Modify your family so it includes a child.
    11. Add an abstract canWatchMovie method to the Human which takes a parameter specifying the movie rating.
    12. Create a MovieRating class that contains a private map with rating as the key and minimum age as the value, populate this map when the class is instantiated. Also include a method which takes two parameters, rating and age and checks the minimum age in the map and returns true or false to indicate whether or not a human with the specified age is allowed to watch a movie with the specified rating.
    13. Implement the canWatchMovie method in the child and adult, in the adult always return true but in the child use the MovieRating class to determine whether the child can watch the movie.
    14. Add a getMovieGoers method to the family that takes a rating as a parameter and returns a collection of all the family members that can watch the movie.
    15. Demonstrate the use on the getMovieGoers method by calling it twice from within the main method of the family and prints out the names of the family members that can watch the movie.

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    You need to do one step at a time. Write some code for the first step, compile it , execute it and verify it works. Then add more code and do the same.
    As you have problems, come back here, post the code and the error messages and your questions.

    What programs have you written so far? Do you know how to create a class or an interface?
    How to add methods to a class etc.

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    We are not going to do your homework for you.

    We will, however, assist you in a problem you are having with code you are writing. Naturally, this means you have written something that isn't working.

    Lets start there.

    What code do you have for this at the moment?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Advanced file system manipulation
    By ranma172 in forum .NET
    Replies: 0
    Last Post: 10-18-2005, 04:16 AM
  2. ANN: Archetype, advanced OO and design patterns tool
    By John Hancock in forum vb.announcements
    Replies: 0
    Last Post: 02-05-2002, 10:46 PM
  3. Advanced VB5/6 Diagnostic Tools V1.2 Released
    By Geoff Kell in forum vb.announcements
    Replies: 0
    Last Post: 02-07-2001, 08:08 AM
  4. Advanced Text Search Engine
    By Bragi Fannar in forum ASP.NET
    Replies: 0
    Last Post: 08-15-2000, 05:56 AM
  5. Advanced find on public subfolders
    By MARTIN J-J jean-jacques.martin in forum Enterprise
    Replies: 0
    Last Post: 05-25-2000, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center