0% found this document useful (0 votes)
98 views1 page

Lab Work-3 (10-01-18)

The document describes an exercise to create a Rocket class in Python using object-oriented programming concepts. It involves defining a Rocket class with initialization and movement methods, creating Rocket objects, and moving them individually or as a fleet to demonstrate their independent positions. It also describes adding a method to calculate distance between rockets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views1 page

Lab Work-3 (10-01-18)

The document describes an exercise to create a Rocket class in Python using object-oriented programming concepts. It involves defining a Rocket class with initialization and movement methods, creating Rocket objects, and moving them individually or as a fleet to demonstrate their independent positions. It also describes adding a method to calculate distance between rockets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy