some one pliz assist me to code the following attached problems
Exercise - Using Objects

This exercise will allow you to demonstrate what you have learned about objects.

Develop a class to represents a human. The head, arms and legs should be properties of the human and should be represented by separate objects. All of your objects should have at least three properties and one method. Ensure that the head, arms and legs can only be constructed from with the same package. The human should include a walk method that uses the legs to actually move.

In the main method of the human, create an instance of a human and set the properties so that it looks like you.

Finally produce a UML class diagram that explains how your classes relate to each other.
Assume that relations between Human and Arm or Leg are compositions. Be careful creating your constructor in Human class. Understand well what composition means.
Exercise - Advanced Objects

This exercise will put what you have just learned about the more advanced site of objects to the test.
We are going to expand on the Human classes that we created in the previous exercise.
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.
Exercise - Exception Handling

We will now make your family safer by adding some exception handling.
1. Create a new Movie class which has two properties, title and rating.
2. Create a new Cinema class, add method addMovieGoers which takes a collection of Humans and another method showMovie which does not take any arguments. Your Cinema class should also have a setMovie method which takes a Movie as an argument.
3. When the addMovieGoers is called on a cinema instance the movie goers should be added to a private collection.
4. Add a new method to your family class that returns all family members.
5. In the main method of the Cinema class call a new static method that creates a family and a cinema then use the addMovieGoers method of the cinema to add the family members. Next create a new movie and use it to set the movie property of the cinema. Finally call cinema.showMovie.
Now, if you were careful your code may have executed without exception but there are quite a few loopholes in your code, to close them do the following.
1. In the showMovie method test whether or not the movie property has been set, if not throw an exception, also add code to empty the Cinema whether the movie was shown or not.
2. In the setMovie method check that the movie title and rating have been set, if not throw an exception.
3. In the addMovieGoers method, check that the movie property has been set and if not throw an exception.
4. Also in the addMovieGoers method check that every member of the collection is a human and that they are old enough to watch the movie, if not throw an exception. Note that although the family has getMovieGoers method, you can't be sure it was used to build the collection.
5. Finally add another static method to the cinema class that demonstrates the usage of the cinema class. Include multiple scenarios to show how the exceptions work.
6. Remember about creating your own exceptions and passing them to the controlling module (here method with scenarios). After an exception occurs your code should stop execution of current scenario and go to another one.
Ensure your code contains plenty of System.out.println statements so that the flow is clear.

Exercise - Advanced Objects

This exercise will put what you have just learned about the more advanced site of objects to the test.
We are going to expand on the Human classes that we created in the previous exercise.
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.


.
Exercise - Exception Handling

We will now make your family safer by adding some exception handling.
1. Create a new Movie class which has two properties, title and rating.
2. Create a new Cinema class, add method addMovieGoers which takes a collection of Humans and another method showMovie which does not take any arguments. Your Cinema class should also have a setMovie method which takes a Movie as an argument.
3. When the addMovieGoers is called on a cinema instance the movie goers should be added to a private collection.
4. Add a new method to your family class that returns all family members.
5. In the main method of the Cinema class call a new static method that creates a family and a cinema then use the addMovieGoers method of the cinema to add the family members. Next create a new movie and use it to set the movie property of the cinema. Finally call cinema.showMovie.
Now, if you were careful your code may have executed without exception but there are quite a few loopholes in your code, to close them do the following.
1. In the showMovie method test whether or not the movie property has been set, if not throw an exception, also add code to empty the Cinema whether the movie was shown or not.
2. In the setMovie method check that the movie title and rating have been set, if not throw an exception.
3. In the addMovieGoers method, check that the movie property has been set and if not throw an exception.
4. Also in the addMovieGoers method check that every member of the collection is a human and that they are old enough to watch the movie, if not throw an exception. Note that although the family has getMovieGoers method, you can't be sure it was used to build the collection.
5. Finally add another static method to the cinema class that demonstrates the usage of the cinema class. Include multiple scenarios to show how the exceptions work.
6. Remember about creating your own exceptions and passing them to the controlling module (here method with scenarios). After an exception occurs your code should stop execution of current scenario and go to another one.
Ensure your code contains plenty of System.out.println statements so that the flow is clear.
Exercise - Reading & Writing Files

In this exercise we will practice working with files.
Develop a simple application that, when run, Welcomes the users and tells them the name of the last person to run the application, this information should be retrieved from a file. After welcoming the users, ask them for their name and save it to the file. Use the ClassLoader and Properties classes to load the file. You will need to investigate writing to files a little (can be also done using Properties class).
Exercise - Recursion

We will now practice (and expand on) what you have learned regarding recursion and working with files by expanding on my demonstration.
Start by copying my code and implementing the IsDirectory and IsNotDirectory objects.
Then make it more usable by indenting the contents of every directory by one more space than its parent is indented by.
Add the number of files and total size of those files in each directory in brackets after each directory name.
Finally add a command line option that allows the user to specify whether files and directories should be written out or just directories.

Comments
you're kidding, right?

Excercise:
Excercise outline - your work
Excercise goal - convince us to help you
End-expectations - working code

1. start coding
2. see where you have errors you can't solve yourself
3. paste relevant code and error messages here
4. ask specific questions
5. stop expecting we will read all your assignment details ánd provide you with a perfect sollution without doing anything yourself

ready-set-GO

@stultuske

I think you misunderstood him, with the above question he wants to test our OOP skills :twisted:

@stultuske

I think you misunderstood him, with the above question he wants to test our OOP skills :twisted:

oooooh, let me give it a go...

public class DingDong{

  public static void main(String args[]){
    for (int i= 0; i < untilTheyUnderstand();i++{
       System.out.println(Printer.getComment());
    }
  }

  public int untilTheyUnderstand(){
     int test = // add value here
     return test;
  }

}

public class Printer{

  public static String getComment(){
     return "DingDong";
  }
}

well.. if he can't find the error in that, it's no use trying to solve that assignment of his

This article has been dead for over six months. Start a new discussion instead.