Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ You must follow the **SDLC process** to refactor the code:
- Once you complete the refactorization, push your changes to your forked repository.
- Create a pull request (PR) to the original repository, explaining the improvements you made and how you followed the **SDLC** approach.

Documentacion:

quiz realizado el 9/13/2024 por Luis Jose -192239 y Sergio Diaz- 192357

Se hizo reafactorizacion al codigo stogare añadiendo:
-2 arrays para guardar tanto los valores de precio como los valores de la cantidad de objetos vendidos
-Se añadio un for que funcionara para calcular el total de la venta

Se refactorizo en ageValidation:
-Se agrego una constante para definir los limites de edad
-Se añadio un scanner para que el usuario pueda ingresar su edad
-Un if adicional para los casos en que se digiten valores menores a 0

Se refactorizo en TaxCalculation:
-Los nombres para TAX_RATE_HIGH, TAX_RATE_LOW y TAX_THRESHOLD añadiendo sus respectivos valores
-Se creo un array que almacenara el valor de los productos
-Se reemplazaron todos los valores magicos
28 changes: 19 additions & 9 deletions src/AgeValidation.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
/* importamos el scanner al codigo */
import java.util.Scanner;
public class AgeValidation {
public static void main(String[] args) {
int age = 18;

if (age >= 18) {
System.out.println("Access granted");
}

if (age < 18) {
System.out.println("Access denied");
/* Asignamos una constante para el limite de edad */
final int LIMIT_AGE = 18 ;
try ( /* Declaramos la variable scanner */ Scanner scanner = new Scanner( System.in )) {
int age ;
/* Le preguntamos al usuario cual es su edad */
System.out.println("What is your age?");
/* usamos el scanner definido anteriormente para guardar el dato que digite el usuario */
age = scanner.nextInt();
/* nos deshacemos de la redundancia de los dos if usando un if-else */
if (age > LIMIT_AGE ) {
System.out.println("Access granted");
} else if (age <= LIMIT_AGE & age>0) {
System.out.println("Access denied");
} else {
System.out.println("Unexisting age");/* Aqui limitamos los valores para que si se llega a ingresar un valor menor a cero aparezca el mensaje de edad inexistente */
}
}
}
}
}
22 changes: 14 additions & 8 deletions src/Store.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
public class Store {
public static void main(String[] args) {
int p1 = 15;
int p2 = 10;
int p3 = 5;

/*Se crea un array para el producto */
int[] PrecioProductos = {13,3,5};

int total1 = p1 * 2;
int total2 = p2 * 3;
int total3 = p3 * 4;
/*Se crea el array cantidad de productos
para verificar cuantos productos se venden*/

int totalSales = total1 + total2 + total3;
int[] CantidadProductos = {2,3,4};

if (totalSales > 50) {
int totalVentas=0;

/*Se hace el calculo para verificar la cantidad de productos vendidos */
for(int i=0; i< PrecioProductos.length;i++){
totalVentas += PrecioProductos[i]*CantidadProductos[i];
}

if (totalVentas > 50) {
System.out.println("Good sales performance");
} else {
System.out.println("Low sales performance");
Expand Down
17 changes: 11 additions & 6 deletions src/TaxCalculation.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
public class TaxCalculation {
public static void main(String[] args) {
double productPrice1 = 100;
double productPrice2 = 200;
double tax1 = productPrice1 * 0.15;
double tax2 = productPrice2 * 0.10;
/* asignamos las constantes que vamos a utilizar */
final double TAX_RATE_HIGH = 0.15;
final double TAX_RATE_LOW = 0.10;
final double TAX_THRESHOLD = 50;
/* utilizamos un array para almacenar los precios de los productos */
double[] productPrice = {100, 200};
/* reemplazamos los valores magicos por las constantes */
double tax1 = productPrice[0] * TAX_RATE_HIGH;
double tax2 = productPrice[1] * TAX_RATE_LOW;
double totalTax = tax1 + tax2;

if (totalTax > 50) {
if (totalTax > TAX_THRESHOLD) {
System.out.println("High total tax: " + totalTax);
} else {
System.out.println("Low tax");
}
}
}
}