Vous êtes sur la page 1sur 1

Lab Work-3

1. Write a program in python using Oops concept that contains following class name,
methods and attributes

 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.
 Create a fleet of rockets, and prove that they are indeed separate Rocket objects.

2. 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. Move several of them around, and print their
final positions to prove that each rocket can move independently of the
other rockets.
 Define the get_distance() method. The method should accept a Rocket
object, and calculate the distance between the current rocket and the rocket
that is passed into the method.
 Use the get_distance() method to print the distances between several of the
rockets in your fleet.

Vous aimerez peut-être aussi