Authors: Valdo Castiglia, Giuliana Giusiano, Shoan Genes
Professor: Josรฉ Clavijo
Due Date: February 17, 2025
This system allows users to create, display, solve, add, save, and retrieve first and second-degree equations through a command-line interface. It was developed as part of Workshop 1, applying data structure techniques, Abstract Data Types (ADTs), and file persistence.
The system recognizes and executes the following commands:
crear <id> <a> <b> [c]โ Creates an equation (1st or 2nd degree)mostrarโ Displays all equations loaded in memoryresolver <id>โ Solves the equation with the specified identifiersumar <id1> <id2> <idResultado>โ Adds two equations and saves the resultguardar <id>โ Saves an equation to disk (.datfile)recuperar <id>โ Retrieves an equation from disksalirโ Frees memory and terminates execution
๐งช Data Structures Used: Linear list for commands and Binary Search Tree (BST) for storing equations.
- Language: C++
- Paradigm: Structured programming with intensive use of Abstract Data Types (ADTs)
- Data Structures:
- Binary Search Tree (BST) for equation storage
- Linked list of strings for command processing
unionto distinguish between 1st and 2nd degree equations- Binary files for data persistence (
.datformat)
- Architecture: Modular design with header files (
.h) and separate ADT implementations
crear eq1 2 3
crear eq2 1 4 5
sumar eq1 eq2 eq3
resolver eq3
guardar eq3
salir| Command | Parameters | Description | Example |
|---|---|---|---|
crear |
<id> <a> <b> [c] |
Creates equation: ax + b = 0 (linear) or axยฒ + bx + c = 0 (quadratic) | crear eq1 2 -5 creates 2x - 5 = 0 |
mostrar |
None | Lists all equations in memory | mostrar |
resolver |
<id> |
Solves the specified equation | resolver eq1 |
sumar |
<id1> <id2> <result_id> |
Adds two equations coefficient-wise | sumar eq1 eq2 eq3 |
guardar |
<id> |
Saves equation to binary file | guardar eq1 |
recuperar |
<id> |
Loads equation from binary file | recuperar eq1 |
salir |
None | Exits program and frees memory | salir |
โโโ include/
โ โโโ abbecuaciones.h # Binary Search Tree ADT for equations
โ โโโ ecuacion.h # Equation ADT (supports 1st & 2nd degree)
โ โโโ comando.h # Command parsing ADT
โ โโโ primergrado.h # First-degree equation operations
โ โโโ segundogrado.h # Second-degree equation operations
โ โโโ ejecucion.h # Command execution handlers
โ โโโ string.h # Custom string ADT
โ โโโ boolean.h # Boolean type definition
โ โโโ grado.h # Degree enumeration
โโโ src/
โ โโโ abbecuaciones.cpp # BST implementation
โ โโโ ecuacion.cpp # Equation management
โ โโโ comando.cpp # Command parsing logic
โ โโโ primergrado.cpp # Linear equation solver
โ โโโ segundogrado.cpp # Quadratic equation solver
โ โโโ ejecucion.cpp # Command execution logic
โ โโโ string.cpp # String utilities
โ โโโ main.cpp # Program entry point
โโโ .gitignore
โโโ README.md
- Linear Equations (1st degree): ax + b = 0
- Quadratic Equations (2nd degree): axยฒ + bx + c = 0
- Linear equations: Direct solution x = -b/a
- Quadratic equations:
- No real solutions (negative discriminant)
- One solution (zero discriminant)
- Two solutions (positive discriminant)
- Binary file storage with
.datextension - Automatic file management for save/load operations
- Prevents overwriting existing files
- Validates command syntax and parameter count
- Checks for duplicate identifiers
- Ensures non-zero leading coefficients
- Validates alphabetic identifiers and numeric coefficients
- C++ compiler (g++, clang++, etc.)
- Standard C++ libraries
# Compile all source files
g++ -I include src/*.cpp -o equation_system
# Run the program
./equation_systemIngrese comando: crear linear 3 -9
linear: 3x - 9 = 0
Ingrese comando: crear quadratic 1 -5 6
quadratic: x^2 - 5x + 6 = 0
Ingrese comando: resolver linear
[ Resultado ]: x = 3.00
Ingrese comando: resolver quadratic
[ Resultado ]: x1 = 3.00, x2 = 2.00
Ingrese comando: salir
[ MENSAJE ]: Hasta la proxima!
This project demonstrates proficiency in:
- Abstract Data Types (ADTs) design and implementation
- Binary Search Trees for efficient data storage and retrieval
- Memory management in C++ with proper allocation/deallocation
- File I/O operations for data persistence
- Modular programming with header/implementation separation
- Command-line interface design and user input validation
This is an academic project developed for educational purposes. The codebase showcases fundamental computer science concepts including data structures, algorithms, and software engineering principles.
This project is part of an academic assignment and is intended for educational use.