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

Untitled

The document contains a test case for the jump function in a Super Mario game, ensuring it correctly increases Mario's height. Additionally, it defines a Mario class with methods for jumping, collecting coins, powering up, and losing lives. An instance of Mario is created to demonstrate the functionality of these methods.

Uploaded by

lokzaaff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Untitled

The document contains a test case for the jump function in a Super Mario game, ensuring it correctly increases Mario's height. Additionally, it defines a Mario class with methods for jumping, collecting coins, powering up, and losing lives. An instance of Mario is created to demonstrate the functionality of these methods.

Uploaded by

lokzaaff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

```javascript

// Import the function to be tested


const { jump } = require('./superMarioGame');

// Test case for the jump function


describe('Super Mario Game', () => {
test('should increase Mario\'s height when jumping', () => {
// Arrange
const initialHeight = 0;
const jumpHeight = 10;

// Act
const finalHeight = jump(initialHeight, jumpHeight);

// Assert
expect(finalHeight).toBe(initialHeight + jumpHeight);
});
});class Mario:
def __init__(self, name):
self.name = name
self.lives = 3
self.coins = 0
self.power = "small"

def jump(self):
print(f"{self.name} is jumping!")

def collect_coin(self):
self.coins += 1
print(f"{self.name} collected a coin! Total coins: {self.coins}")

def power_up(self):
if self.power == "small":
self.power = "big"
print(f"{self.name} powered up to big Mario!")
elif self.power == "big":
self.power = "fire"
print(f"{self.name} powered up to fire Mario!")
else:
print(f"{self.name} is already fire Mario!")

def die(self):
self.lives -= 1
if self.lives > 0:
print(f"{self.name} lost a life! Lives left: {self.lives}")
else:
print(f"{self.name} has no lives left. Game over!")

# Create an instance of Mario


player1 = Mario("Mario")

# Test the Mario class methods


player1.jump()
player1.collect_coin()
player1.power_up()
player1.power_up()
player1.die()
player1.die()
player1.die()

You might also like