Skip to content

Balloon

SimonStnn edited this page Mar 8, 2024 · 7 revisions

This class represents a balloon that is dislpayed on the screen.

UML class diagram

classDiagram

class Baloon {
    -element HTMLDivElement
    -duration number
    -popSound HTMLAudioElement

    +isRising() boolean
    +rise() void
    +remove() void
    +pop() Promise~void~
}
Loading

Constructor

Balloon()

Creates a new balloon and appends it to the balloon container.

Attributes

The balloon has no public attributes.

Properties

The balloon has no public properties.

Methods

isRising(): boolean

Returns true if the balloon is rising, false otherwise.

rise(): void

Makes the balloon rise. If the balloon is already rising, this method does nothing.

remove(): void

Removes the balloon from the screen.

Tip

This should be called when the user didn't click the balloon.

pop(): Promise<void>

Pops the balloon and calls the remove method. Also will play the pop sound.

This will also increment the balloon count by 1.

Tip

This should be called when the user clicks the balloon.