Hi everyone,

I just started working with Python and programming in general (i chose it as a school subject for this year) and i received a task(scroll a bit more down).. since im a total newbie with Python in general.. i was hoping someone could please explain this task in detail, I am writing an exam over this exact same task in a few days time but i do not fully understand it

here is my task:

" Task - Classes And Instantiating Objects Based On The Class

Build a class called Corvette

Public Methods of Corvette

ShootExocetMissile

EvadeTorpedoes

EvadeTorpedoes

Private_Method_of_Corvette

_AbandonShip_

Instantiate Your Object

Generating A Random Number In Python

Determining Likelihood Of Something Occuring

Build a class called Corvette (represents one of the new navy frigates)

Properties of the Corvette

ShipName

CaptainsName

ShipCrew

NumberOfExocetMissiles

Public Methods of Corvette

ShootExocetMissile(TargetName, DistanceAway)

Remember to decrement NumberOfExocetMissiles

What do you do when you are out of missiles ?

Return 0 if successful else 1 if fails. Use random number generator to decides success or fail with 75 % chance of success

EvadeTorpedoes(DirectionToTurn=[port, starboard], Speed=[Full, Half, Stop], FireCounterMeasures=True/ False, TorpedoeDirection=[port, starboard])

If TorpedoDirection = port and DirectionToTurn = port then LikelihoodOfHit = 20 % otherwise 80 %

If TorpedoDirection = starboard and DirectionToTurn = starboard then LikelihoodOfHit = 20 % otherwise 80 %

If hit then call private method AbandonShip and return 1 else return 0 (means ship not hit)

Private Method of Corvette

__AbandonShip__

See if you can get the PC to make a noise for 10 seconds and then return control to calling stub

Instantiate Your Object

Give the object values

Change the captains name

You have 10 Exocet missiles

Shoot two Exocet missiles. What happened to each missile, did they hit or not

Show NumberOfExocetMissiles

A torpedo is shot at you - do you get hit ?

Generating A Random Number In Python

import random

random.randint(0, 100) # generate random integer between 0 and 100

Determining Likelihood Of Something Happening

Suppose there is a 20 % chance (likelihood) of it raining.

To program this we generate a random number (integer) whose value lies between 0 and 1, and if this number is <= 20 then it will rain

def WillEventOccur(ChanceOfEventOccuring = 20): # 20% chance of event occuring

import random

if random.randint(0,100) <= ChanceOfEventOccuring: # test if random number <= 20

return True # event has occured

else:

return False # event does not occur

"

thanks in advance for any help, i truly appreciate it.