Repository: fabriciosantana/poo
Pull request #109: Exercicios 02 e Resumo 02
Author: login: PedroPignata
Labels: name: Review effort 2/5
Created: 2025-03-06T23:43:46Z | Merged: 2025-03-14T01:49:34Z

### **PR Type**
Enhancement, Tests


___

### **Description**
- Added `HeartRates` class to calculate heart rate metrics.

- Introduced `HealthProfile` class for BMI and health metrics.

- Implemented `PalindromeChecker` for validating and checking palindromes.

- Developed `CollatzSequence` to compute Collatz sequence and sum.

- Created `MedianCalculator` to find the median of three numbers.


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>HeartRates.java</strong><dd><code>Added `HeartRates` class for heart rate calculations</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java

<li>Added <code>HeartRates</code> class to calculate age, max heart rate, and target <br>heart rate.<br> <li> Included a <code>Main</code> class for user interaction and displaying results.<br> <li> Utilized user input for personal and birth details.


</details>


  </td>
  <td><a href="https://github.com/fabriciosantana/poo/pull/109/files#diff-68b7ef6c9f19b1d9ce375e74b398adb00891c6047089a96e0f711869475d1e1a">+100/-0</a>&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>HealthProfile.java</strong><dd><code>Introduced `HealthProfile` class for health metrics</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java

<li>Added <code>HealthProfile</code> class for BMI, age, and heart rate calculations.<br> <li> Included <code>HealthProfileApp</code> for user interaction and displaying health <br>metrics.<br> <li> Added BMI reference table for user guidance.


</details>


  </td>
  <td><a href="https://github.com/fabriciosantana/poo/pull/109/files#diff-68ea26a5ead748ef25c4e5ead4579ecb0c8ae42bdccaa20c761d13d195ca4e20">+133/-0</a>&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>PalindromeChecker.java</strong><dd><code>Implemented `PalindromeChecker` for palindrome validation</code></dd></summary>
<hr>

assignments/08-palindrome/submissions/pedro-pignata/src/PalindromeChecker.java

<li>Implemented <code>PalindromeChecker</code> to validate and check palindrome <br>sequences.<br> <li> Added input validation to ensure non-empty strings.<br> <li> Provided user interaction for checking palindrome status.


</details>


  </td>
  <td><a href="https://github.com/fabriciosantana/poo/pull/109/files#diff-780768d525d90a391b238560c9179ff4be713578dd5a7a205b294f074630de62">+48/-0</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>CollatzSequence.java</strong><dd><code>Added `CollatzSequence` for sequence computation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

assignments/09-collatz/submissions/pedro-pignata/src/CollatzSequence.java

<li>Developed <code>CollatzSequence</code> to compute Collatz sequence and sum.<br> <li> Added input validation for positive integers.<br> <li> Displayed the sequence and sum of terms.


</details>


  </td>
  <td><a href="https://github.com/fabriciosantana/poo/pull/109/files#diff-a40b056b721fdc630a02cd6091f05e04d59c2d36f404f98848e87cb17d6a1990">+50/-0</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>MedianCalculator.java</strong><dd><code>Developed `MedianCalculator` for median determination</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

assignments/10-median/submissions/pedro-pignata/src/MedianCalculator.java

<li>Created <code>MedianCalculator</code> to find the median of three integers.<br> <li> Included user interaction for input and displaying results.<br> <li> Implemented logic to determine the median efficiently.


</details>


  </td>
  <td><a href="https://github.com/fabriciosantana/poo/pull/109/files#diff-b7b3c8d9767e0270c96170f781d8e931cb51b273ee788073958faa765c06bee9">+33/-0</a>&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary>  Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about Qodo Merge usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>


Diff:
diff --git a/assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java b/assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java
new file mode 100644
index 000000000..1ac3b5cc9
--- /dev/null
+++ b/assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java
@@ -0,0 +1,73 @@
+import java.util.Scanner;
+
+class HeartRates {
+    private String firstName;
+    private String lastName;
+    private int dayOfBirth;
+    private int monthOfBirth;
+    private int yearOfBirth;
+
+    public HeartRates(String firstName, String lastName, int dayOfBirth, int monthOfBirth, int yearOfBirth) {
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.dayOfBirth = dayOfBirth;
+        this.monthOfBirth = monthOfBirth;
+        this.yearOfBirth = yearOfBirth;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public int getDayOfBirth() {
+        return dayOfBirth;
+    }
+
+    public void setDayOfBirth(int dayOfBirth) {
+        this.dayOfBirth = dayOfBirth;
+    }
+
+    public int getMonthOfBirth() {
+        return monthOfBirth;
+    }
+
+    public void setMonthOfBirth(int monthOfBirth) {
+        this.monthOfBirth = monthOfBirth;
+    }
+
+    public int getYearOfBirth() {
+        return yearOfBirth;
+    }
+
+    public void setYearOfBirth(int yearOfBirth) {
+        this.yearOfBirth = yearOfBirth;
+    }
+
+    public int calculateAge(int currentYear) {
+        return currentYear - yearOfBirth;
+    }
+
+    public int calculateMaxHeartRate() {
+        int age = calculateAge(2025);
+        return 220 - age;
+    }
+
+    public String calculateTargetHeartRate() {
+        int maxHeartRate = calculateMaxHeartRate();
+        int targetMin = (int) (maxHeartRate * 0.50);
+        int targetMax = (int) (maxHeartRate * 0.85);
+        return targetMin + " bpm - " + targetMax + " bpm";
+    }
+}
diff --git a/assignments/06-heart/submissions/pedro-pignata/src/Main.java b/assignments/06-heart/submissions/pedro-pignata/src/Main.java
new file mode 100644
index 000000000..3d4ecf7c0
--- /dev/null
+++ b/assignments/06-heart/submissions/pedro-pignata/src/Main.java
@@ -0,0 +1,28 @@
+import java.util.Scanner;
+
+public class Main {
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+
+        System.out.print("Digite o seu primeiro nome: ");
+        String firstName = scanner.next();
+
+        System.out.print("Digite o seu sobrenome: ");
+        String lastName = scanner.next();
+
+        System.out.print("Digite sua data de nascimento (dia, mês e ano separados por espaço): ");
+        int dayOfBirth = scanner.nextInt();
+        int monthOfBirth = scanner.nextInt();
+        int yearOfBirth = scanner.nextInt();
+
+        HeartRates person = new HeartRates(firstName, lastName, dayOfBirth, monthOfBirth, yearOfBirth);
+
+        System.out.println("\nNome: " + person.getFirstName() + " " + person.getLastName());
+        System.out.println("Data de nascimento: " + person.getDayOfBirth() + "/" + person.getMonthOfBirth() + "/" + person.getYearOfBirth());
+        System.out.println("Idade: " + person.calculateAge(2025) + " anos");
+        System.out.println("Frequência cardíaca máxima: " + person.calculateMaxHeartRate() + " bpm");
+        System.out.println("Faixa de frequência cardíaca alvo: " + person.calculateTargetHeartRate());
+
+        scanner.close();
+    }
+}
diff --git a/assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java b/assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java
new file mode 100644
index 000000000..8cf6e5adb
--- /dev/null
+++ b/assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java
@@ -0,0 +1,86 @@
+import java.util.Scanner;
+
+class HealthProfile {
+    private String firstName;
+    private String lastName;
+    private char gender;
+    private int dayOfBirth;
+    private int monthOfBirth;
+    private int yearOfBirth;
+    private double heightInInches;
+    private double weightInPounds;
+
+    public HealthProfile(String firstName, String lastName, char gender, int dayOfBirth, int monthOfBirth, int yearOfBirth, double heightInInches, double weightInPounds) {
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.gender = gender;
+        this.dayOfBirth = dayOfBirth;
+        this.monthOfBirth = monthOfBirth;
+        this.yearOfBirth = yearOfBirth;
+        this.heightInInches = heightInInches;
+        this.weightInPounds = weightInPounds;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public char getGender() {
+        return gender;
+    }
+
+    public void setGender(char gender) {
+        this.gender = gender;
+    }
+
+    public int getDayOfBirth() {
+        return dayOfBirth;
+    }
+
+    public int getMonthOfBirth() {
+        return monthOfBirth;
+    }
+
+    public int getYearOfBirth() {
+        return yearOfBirth;
+    }
+
+    public double getHeightInInches() {
+        return heightInInches;
+    }
+
+    public double getWeightInPounds() {
+        return weightInPounds;
+    }
+
+    public int calculateAge(int currentYear) {
+        return currentYear - yearOfBirth;
+    }
+
+    public int calculateMaxHeartRate() {
+        return 220 - calculateAge(2025);
+    }
+
+    public String calculateTargetHeartRate() {
+        int maxHeartRate = calculateMaxHeartRate();
+        int targetMin = (int) (maxHeartRate * 0.50);
+        int targetMax = (int) (maxHeartRate * 0.85);
+        return targetMin + " bpm - " + targetMax + " bpm";
+    }
+
+    public double calculateBMI() {
+        return (weightInPounds * 703) / (heightInInches * heightInInches);
+    }
+}
diff --git a/assignments/07-health/submissions/pedro-pignata/src/Main.java b/assignments/07-health/submissions/pedro-pignata/src/Main.java
new file mode 100644
index 000000000..b6dd5e229
--- /dev/null
+++ b/assignments/07-health/submissions/pedro-pignata/src/Main.java
@@ -0,0 +1,48 @@
+import java.util.Scanner;
+
+public class Main {
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+
+        System.out.print("Digite seu primeiro nome: ");
+        String firstName = scanner.nextLine();
+
+        System.out.print("Digite seu sobrenome: ");
+        String lastName = scanner.nextLine();
+
+        System.out.print("Digite seu gênero (M/F): ");
+        char gender = scanner.next().charAt(0);
+
+        System.out.print("Digite sua data de nascimento (dia, mês e ano separados por espaço): ");
+        int day = scanner.nextInt();
+        int month = scanner.nextInt();
+        int year = scanner.nextInt();
+
+        System.out.print("Digite sua altura em polegadas: ");
+        double height = scanner.nextDouble();
+
+        System.out.print("Digite seu peso em libras: ");
+        double weight = scanner.nextDouble();
+
+        HealthProfile profile = new HealthProfile(firstName, lastName, gender, day, month, year, height, weight);
+
+        System.out.println("\n--- Informações do Paciente ---");
+        System.out.println("Nome: " + profile.getFirstName() + " " + profile.getLastName());
+        System.out.println("Gênero: " + (profile.getGender() == 'M' ? "Masculino" : "Feminino"));
+        System.out.println("Data de nascimento: " + profile.getDayOfBirth() + "/" + profile.getMonthOfBirth() + "/" + profile.getYearOfBirth());
+        System.out.println("Idade: " + profile.calculateAge(2025) + " anos");
+        System.out.println("Altura: " + profile.getHeightInInches() + " polegadas");
+        System.out.println("Peso: " + profile.getWeightInPounds() + " libras");
+        System.out.printf("Índice de Massa Corporal (BMI): %.1f\n", profile.calculateBMI());
+        System.out.println("Frequência cardíaca máxima: " + profile.calculateMaxHeartRate() + " bpm");
+        System.out.println("Faixa de frequência cardíaca alvo: " + profile.calculateTargetHeartRate());
+
+        System.out.println("\n--- Tabela de Referência do BMI ---");
+        System.out.println("Menos de 18.5  | Abaixo do peso");
+        System.out.println("18.5 – 24.9    | Peso normal");
+        System.out.println("25.0 – 29.9    | Sobrepeso");
+        System.out.println("30.0 ou mais   | Obesidade");
+
+        scanner.close();
+    }
+}
\ No newline at end of file
diff --git a/assignments/08-palindrome/submissions/pedro-pignata/src/PalindromeChecker.java b/assignments/08-palindrome/submissions/pedro-pignata/src/PalindromeChecker.java
new file mode 100644
index 000000000..6a329fb2b
--- /dev/null
+++ b/assignments/08-palindrome/submissions/pedro-pignata/src/PalindromeChecker.java
@@ -0,0 +1,48 @@
+import java.util.Scanner;
+
+public class PalindromeChecker {
+
+    public static boolean isValidInput(String input) {
+        return input != null && !input.trim().isEmpty();
+    }
+
+    public static boolean isPalindrome(String input) {
+        if (input == null) return false;
+        input = input.toLowerCase().replaceAll("\\s+", "");
+        int left = 0;
+        int right = input.length() - 1;
+        
+        while (left < right) {
+            if (input.charAt(left) != input.charAt(right)) {
+                return false;
+            }
+            left++;
+            right--;
+        }
+        return true;
+    }
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        String input;
+        
+        while (true) {
+            System.out.print("Digite uma sequência: ");
+            input = scanner.nextLine().trim();
+            
+            if (isValidInput(input)) {
+                break;
+            } else {
+                System.out.println("Erro: A entrada não pode estar vazia.");
+            }
+        }
+        
+        if (isPalindrome(input)) {
+            System.out.println("A sequência \"" + input + "\" é um palíndromo.");
+        } else {
+            System.out.println("A sequência \"" + input + "\" não é um palíndromo.");
+        }
+        
+        scanner.close();
+    }
+}
diff --git a/assignments/09-collatz/submissions/pedro-pignata/src/CollatzSequence.java b/assignments/09-collatz/submissions/pedro-pignata/src/CollatzSequence.java
new file mode 100644
index 000000000..a21ac9896
--- /dev/null
+++ b/assignments/09-collatz/submissions/pedro-pignata/src/CollatzSequence.java
@@ -0,0 +1,50 @@
+import java.util.Scanner;
+
+public class CollatzSequence {
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+
+        System.out.print("Digite um número inteiro positivo: ");
+        if (!scanner.hasNextInt()) {
+            System.out.println("Erro: O número deve ser um inteiro positivo.");
+            scanner.close();
+            return;
+        }
+
+        int semente = scanner.nextInt();
+        scanner.close();
+
+        if (semente < 1) {
+            System.out.println("Erro: O número deve ser um inteiro positivo.");
+            return;
+        }
+
+        int soma = calculateCollatzSum(semente);
+        System.out.println("Soma dos termos: " + soma);
+    }
+
+    public static int nextCollatz(int n) {
+        if (n < 1) {
+            throw new IllegalArgumentException("O número deve ser um inteiro positivo.");
+        }
+        return (n % 2 == 0) ? (n / 2) : ((n * 3) + 1);
+    }
+
+    public static int calculateCollatzSum(int n) {
+        if (n < 1) {
+            throw new IllegalArgumentException("O número deve ser um inteiro positivo.");
+        }
+
+        int soma = 0;
+        System.out.print("Sequência de Collatz: ");
+        while (n != 1) {
+            System.out.print(n + " → ");
+            soma += n;
+            n = nextCollatz(n);
+        }
+        System.out.println(n);
+        soma += n;
+        return soma;
+    }
+}
diff --git a/assignments/10-median/submissions/pedro-pignata/src/MedianCalculator.java b/assignments/10-median/submissions/pedro-pignata/src/MedianCalculator.java
new file mode 100644
index 000000000..137008019
--- /dev/null
+++ b/assignments/10-median/submissions/pedro-pignata/src/MedianCalculator.java
@@ -0,0 +1,33 @@
+import java.util.Scanner;
+
+public class MedianCalculator {
+    
+    public static int findMedian(int a, int b, int c) {
+        if ((a >= b && a <= c) || (a <= b && a >= c)) {
+            return a;
+        } else if ((b >= a && b <= c) || (b <= a && b >= c)) {
+            return b;
+        } else {
+            return c;
+        }
+    }
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+
+        System.out.print("Digite o primeiro número: ");
+        int num1 = scanner.nextInt();
+
+        System.out.print("Digite o segundo número: ");
+        int num2 = scanner.nextInt();
+
+        System.out.print("Digite o terceiro número: ");
+        int num3 = scanner.nextInt();
+
+        int mediana = findMedian(num1, num2, num3);
+
+        System.out.println("A mediana dos números é: " + mediana);
+        
+        scanner.close();
+    }
+}
diff --git a/challenges/01-reverse/src/StringReverser.java b/challenges/01-reverse/src/StringReverser.java
index f1f18440d..99bd6b981 100644
--- a/challenges/01-reverse/src/StringReverser.java
+++ b/challenges/01-reverse/src/StringReverser.java
@@ -1,28 +1,28 @@
-import java.util.Scanner;
-
-public class StringReverser {
-
-    public static void main(String[] args) {
-        try(Scanner scanner = new Scanner(System.in)){
-            System.out.print("Digite uma string: ");
-            String input = scanner.nextLine();
-            System.out.printf("String invertida: %s\n", reverse(input));
-       }
-    }
-
-    public static String reverse(String inputString) {
-
-        if (inputString.isEmpty()) {
-            throw new IllegalArgumentException("A string não pode ser nula.");
-        }
-
-        String reversedString = new String();
-  
-        for (int i = inputString.length()-1; i >= 0; i--) {
-            reversedString += inputString.charAt(i);
-        }
-        
-        return reversedString;
- 
-    }
+import java.util.Scanner;
+
+public class StringReverser {
+
+    public static void main(String[] args) {
+        try(Scanner scanner = new Scanner(System.in)){
+            System.out.print("Digite uma string: ");
+            String input = scanner.nextLine();
+            System.out.printf("String invertida: %s\n", reverse(input));
+       }
+    }
+
+    public static String reverse(String inputString) {
+
+        if (inputString.isEmpty()) {
+            throw new IllegalArgumentException("A string não pode ser nula.");
+        }
+
+        String reversedString = new String();
+  
+        for (int i = inputString.length()-1; i >= 0; i--) {
+            reversedString += inputString.charAt(i);
+        }
+        
+        return reversedString;
+ 
+    }
 }
\ No newline at end of file
diff --git a/readings/02-first/pedro-pignata.pdf b/readings/02-first/pedro-pignata.pdf
new file mode 100644
index 000000000..8bfe04968
Binary files /dev/null and b/readings/02-first/pedro-pignata.pdf differ


Reviews:
user: login: fabriciosantana
body: Atualizar seu repositório com últimos testes

Palindrome OK
Collatz OK
state: CHANGES_REQUESTED
author_association: OWNER
submitted_at: 2025-03-07T02:58:29Z
user: login: fabriciosantana
body: Atualizar repositório para pegar ajustes nos testes que precisei fazer.

Median OK
Collatz OK
Palindrome OK

state: CHANGES_REQUESTED
author_association: OWNER
submitted_at: 2025-03-07T03:00:53Z
user: login: fabriciosantana
body: separar a classe main em um arquivo próprio. Você compilou o código antes do envio?

assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java:75: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
state: CHANGES_REQUESTED
author_association: OWNER
submitted_at: 2025-03-10T02:14:29Z
user: login: fabriciosantana
body: Revisar comentários
state: CHANGES_REQUESTED
author_association: OWNER
submitted_at: 2025-03-10T02:16:16Z
user: login: PedroPignata
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T11:57:42Z
user: login: PedroPignata
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-10T12:04:13Z
user: login: fabriciosantana
body: Pull request aceito e realizado merge.
state: APPROVED
author_association: OWNER
submitted_at: 2025-03-14T01:48:33Z

Review comments:
path: assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java
user: login: fabriciosantana
body: separar a classe main em um arquivo próprio. Você compilou o código antes do envio?

assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java:75: error: class Main is public, should be declared in a file named Main.java
public class Main {
^

created_at: 2025-03-10T02:14:53Z
author_association: OWNER
path: assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java
user: login: fabriciosantana
body: o nome das classes devem seguir a especificação.

assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java:88: error: class HealthProfileApp is public, should be declared in a file named HealthProfileApp.java
public class HealthProfileApp {
       ^
1 error
created_at: 2025-03-10T02:15:40Z
author_association: OWNER
path: assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java
user: login: PedroPignata
body: Resolvi o problema, está certo agora professor ?
created_at: 2025-03-10T11:57:41Z
author_association: CONTRIBUTOR
path: assignments/07-health/submissions/pedro-pignata/src/HealthProfile.java
user: login: PedroPignata
body: Arrumei o problema porfessor, confira se está certo paara mim

created_at: 2025-03-10T12:04:12Z
author_association: CONTRIBUTOR

PR comments:
user: login: qodo-code-review[bot]
created_at: 2025-03-06T23:44:11Z
body: _Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account [here](https://app.qodo.ai/qodo-merge)._

## PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

<table>
<tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 2 🔵🔵⚪⚪⚪</td></tr>
<tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr>
<tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr>
<tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br>

<details><summary><a href='https://github.com/fabriciosantana/poo/pull/109/files#diff-68b7ef6c9f19b1d9ce375e74b398adb00891c6047089a96e0f711869475d1e1aR63-R64'><strong>Hardcoded Year</strong></a>

The calculateAge and calculateMaxHeartRate methods use a hardcoded year (2025) which could lead to incorrect calculations as time passes. Consider accepting the current year as a parameter or using the system's current year.
</summary>

```java
int age = calculateAge(2025);
return 220 - age;
```

</details>

<details><summary><a href='https://github.com/fabriciosantana/poo/pull/109/files#diff-a40b056b721fdc630a02cd6091f05e04d59c2d36f404f98848e87cb17d6a1990R31-R31'><strong>Integer Overflow</strong></a>

The Collatz sequence calculation could potentially cause integer overflow for large inputs, especially in the (n * 3) + 1 operation. Consider adding bounds checking or using long instead of int.
</summary>

```java
return (n % 2 == 0) ? (n / 2) : ((n * 3) + 1);
```

</details>

<details><summary><a href='https://github.com/fabriciosantana/poo/pull/109/files#diff-780768d525d90a391b238560c9179ff4be713578dd5a7a205b294f074630de62R11-R11'><strong>Special Characters</strong></a>

The isPalindrome method only removes whitespace but doesn't handle special characters or punctuation, which might lead to unexpected results when checking phrases with punctuation.
</summary>

```java
input = input.toLowerCase().replaceAll("\\s+", "");
```

</details>

</td></tr>
</table>

author_association: CONTRIBUTOR
user: login: qodo-code-review[bot]
created_at: 2025-03-06T23:44:29Z
body: _Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account [here](https://app.qodo.ai/qodo-merge)._

## PR Code Suggestions ✨

<!-- 1688a24 -->

Explore these optional code suggestions:

<table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td>
<td>



<details><summary>Prevent integer overflow</summary>

___


**For large values of <code>n</code>, the calculation <code>(n * 3) + 1</code> could potentially cause an <br>integer overflow. Consider using <code>long</code> instead of <code>int</code> to handle larger numbers <br>safely.**

[assignments/09-collatz/submissions/pedro-pignata/src/CollatzSequence.java [27-32]](https://github.com/fabriciosantana/poo/pull/109/files#diff-a40b056b721fdc630a02cd6091f05e04d59c2d36f404f98848e87cb17d6a1990R27-R32)

```diff
-public static int nextCollatz(int n) {
+public static long nextCollatz(long n) {
     if (n < 1) {
         throw new IllegalArgumentException("O número deve ser um inteiro positivo.");
     }
     return (n % 2 == 0) ? (n / 2) : ((n * 3) + 1);
 }
```

- [ ] **Apply this suggestion** <!-- /improve --apply_suggestion=0 -->

<details><summary>Suggestion importance[1-10]: 9</summary>

__

Why: This is a critical suggestion that addresses a potential integer overflow issue with the Collatz sequence calculation. For large input values, (n * 3) + 1 could exceed the int range, causing unexpected behavior. Using long instead would prevent this serious bug.


</details></details></td><td align=center>High

</td></tr><tr><td rowspan=1>General</td>
<td>



<details><summary>Remove hardcoded year value<!-- not_implemented --></summary>

___


**The <code>calculateMaxHeartRate()</code> method uses a hardcoded year (2025) to calculate <br>age. This could lead to incorrect calculations if the program is used in <br>different years. Consider passing the current year as a parameter to make the <br>method more flexible and accurate.**

[assignments/06-heart/submissions/pedro-pignata/src/HeartRates.java [58-65]](https://github.com/fabriciosantana/poo/pull/109/files#diff-68b7ef6c9f19b1d9ce375e74b398adb00891c6047089a96e0f711869475d1e1aR58-R65)

```diff
 public int calculateAge(int currentYear) {
     return currentYear - yearOfBirth;
 }
 
-public int calculateMaxHeartRate() {
-    int age = calculateAge(2025);
+public int calculateMaxHeartRate(int currentYear) {
+    int age = calculateAge(currentYear);
     return 220 - age;
 }
```

- [ ] **Apply this suggestion** <!-- /improve --apply_suggestion=1 -->

<details><summary>Suggestion importance[1-10]: 8</summary>

__

Why: The suggestion correctly identifies a significant issue where the year 2025 is hardcoded in the calculateMaxHeartRate() method. Making this parameter dynamic would improve the code's flexibility and accuracy, preventing incorrect calculations as time passes.


</details></details></td><td align=center>Medium

</td></tr>
<tr><td align="center" colspan="2">

- [ ] Update <!-- /improve --more_suggestions=true -->

</td><td></td></tr></tbody></table>
author_association: CONTRIBUTOR
user: login: PedroPignata
created_at: 2025-03-10T17:08:40Z
body: Refiz as questões

author_association: CONTRIBUTOR