Assignment on Object Oriented Programming in python

Hello Everyone.......!

Now it's time for the assignment. This assignment is based on chapter 4 Object Oriented Programming in python.


## Object Oriented Programming ##
(1) Create the Rocket class as per the following details.
? Define the Rocket() class.
? Define the init () method, which sets an x and a y value for
each Rocket object.
? Define the move_up() method.
? Create a Rocket object.
? Print the object.
? Print the object's y-value.
? Move the rocket up, and print its y-value again.

(2) There are enough new concepts here that you might want to try re-creating the Rocket class as it has been developed so far.
Re-create the Rocket class as it has been developed so far:
? Define the Rocket() class.
? Define the _init _() method. Let your _init _() method accept x
and y values for the initial position of the rocket. Make sure the
default behavior is to position the rocket at (0,0).
? Define the move_rocket() method. The method should accept
an amount to move left or right, and an amount to move up or
down.
? Create a Rocket object. Move the rocket around, printing its
position after each move.
? Create a small fleet of rockets (multiple objects). Move
several of them around, and print their final positions to prove
that each rocket can move independently of the other rockets.

(3) Modeling a person is a classic exercise for people who are trying to learn how to write classes. We are all familiar with characteristics and behaviors of people, so it is a good exercise to try.
? Define a Person() class.
? In the init() function, define several attributes of a person.
Good attributes to consider are name, age, place of birth, and
anything else you like to know about the people in your life.
? Write one method. This could be as simple
as introduce_yourself(). This method would print out a statement such as, "Hello, my name is Ankit."
? You could also make a method such as age_person(). A simple version of this method would just add 1 to the person's age.
o A more complicated version of this method would involve
storing the person's birthdate rather than their age, and then
calculating the age whenever the age is requested. But
dealing with dates and times is not particularly easy if
you've never done it in any other programming language
before.
? Create a person, set the attribute values appropriately, and print out information about the person.
? Call your method on the person you created. Make sure your
method executed properly; if the method does not print anything
out directly, print something before and after calling the method to make sure it did what it was supposed to.

(4) Modeling a car is another classic exercise.
? Define a Car() class.
? In the init () function, define several attributes of a car. Some
good attributes to consider are make (Subaru, Audi, Volvo...),
model (Outback, allroad, C30), year, num_doors, owner, or any
other aspect of a car you care to include in your class.
? Write one method. This could be something such
as describe_car(). This method could print a series of statements that describe the car, using the information that is stored in the attributes. You could also write a method that adjusts the mileage of the car.
? Create a car object, and use your method.
? Create several car objects with different values for the attributes.
Use your method on several of your cars.



Best regards from,

msbtenote:)

THANK YOU!

Comments