https://github.com/annielymariah/game-classes-builder-dio
This repository contains the solution to the "Escrevendo as classes de um Jogo" challenge proposed by DIO.me. The project involves creating a generic Hero class with properties like name, age, and types. The class also includes some methods based on the hero's type, showcasing key programming concepts like classes, objects, and decision structures.
https://github.com/annielymariah/game-classes-builder-dio
javascript nodejs programming-logic
Last synced: 3 months ago
JSON representation
This repository contains the solution to the "Escrevendo as classes de um Jogo" challenge proposed by DIO.me. The project involves creating a generic Hero class with properties like name, age, and types. The class also includes some methods based on the hero's type, showcasing key programming concepts like classes, objects, and decision structures.
- Host: GitHub
- URL: https://github.com/annielymariah/game-classes-builder-dio
- Owner: annielymariah
- Created: 2024-11-23T02:59:01.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-12-04T03:50:21.000Z (7 months ago)
- Last Synced: 2025-02-02T15:11:42.702Z (5 months ago)
- Topics: javascript, nodejs, programming-logic
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π‘οΈ Game Classes Builder πΉ
## Description
This project is a solution to the "Escrevendo as classes de um Jogo" challenge proposed by the DIO.me course. The objective is to create a generic `Hero` class representing a character in an adventure game, with properties like name, age, and type (e.g., warrior, mage, monk, ninja). Additionally, the class must have an `attack` method that displays a message based on the hero's type, showing what attack they used.
## Challenge Requirements
The `Hero` class must meet the following requirements:
- **Properties**:
- `name` (string): The hero's name.
- `age` (number): The hero's age.
- `type` (string): The hero's type (e.g., "warrior", "mage", "monk", "ninja").
- **Methods**:
- `attack()` (method): Displays the message:
- `"The {type} attacked using {attack}"`
- Where `{type}` is the hero's type (e.g., "warrior", "mage", etc.).
- `{attack}` will depend on the hero's type:
- **mage** β `"used magic"`
- **warrior** β `"used a sword"`
- **monk** β `"used martial arts"`
- **ninja** β `"used a shuriken"`## Expected Output
The output should be in the following format, based on the heroβs type:
- `"The {type} attacked using {attack}"`
For example:
- **Warrior**: `"The warrior attacked using a sword"`
- **Mage**: `"The mage attacked using magic"`
- **Monk**: `"The monk attacked using martial arts"`
- **Ninja**: `"The ninja attacked using a shuriken"`## Tools and Concepts Used
- Classes
- Objects
- Methods
- String Manipulation
- Conditional Logic## How to Run the Project
### Install Node.js
Make sure Node.js is installed on your computer. If not, download it from the official website:- [Node.js Official Site](https://nodejs.org/)
### Clone this repository:
```bash
git clone https://github.com/annielymariah/game-classes-builder-DIO.git
```### Navigate to the project directory:
```bash
cd game-classes-builder-DIO
```### Run the script:
After cloning the repository, execute the project with:```bash
node main.js
```### Interact with the program:
The script will create a hero and call the `attack()` method, displaying the attack message based on the hero's type.