2.5/10
public roast
verdict: needs_serious_help
Java
40 lines
3 focus points
"A catastrophe of text manipulation, a travesty of Java"
Here is the breakdown of what hurt your score, plus a cleaned-up version you can use as a starting point. If the roast feels fair, share it. If it feels unfair, paste better code next time.
score
2.5 / 10
fixed output
22 lines
line delta
-18
// summary
Your strongest next move is to fix the highest-severity issue first, then compare the cleanup against the original before shipping anything.
// sharing
Public roasts can land in the leaderboard. Private reviews stay out of it and are better for real code you do not want exposed.
// compare
Use the original and fixed blocks below to spot naming, logic, and structure changes quickly instead of reading the whole thing twice.
//your_submission
TextTorturer.java
import java.util.Scanner;
public class ManipuladordeTexto {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Insira um bloco de texto:");
String texto = scanner.nextLine();
String textoSemEspacos = texto.trim();
System.out.println("Texto com trim(): " + textoSemEspacos);
if (textoSemEspacos.length() >= 5) {
String parte = textoSemEspacos.substring(0, 5);
System.out.println("substring(0,5): " + parte);
} else {
System.out.println("texto muito curto para usar substring(0,5).");
}
String textoSubstituido = textoSemEspacos.replace("a", "@");
System.out.println("replace('a','@'): " + textoSubstituido);
System.out.println("toUpperCase(): " + textoSemEspacos.toUpperCase());
System.out.println("toLowerCase(): " + textoSemEspacos.toLowerCase());
String[] palavras = textoSemEspacos.split(" ");
System.out.println("Palavras separadas com split():");
for (String palavra : palavras) {
System.out.println(palavra);
}
int numero = 2026;
String numeroConvertido = String.valueOf(numero);
System.out.println("String.valueOf(numero): " + numeroConvertido);
}
}
//detailed_analysis
!
Code Organization
Your code is a linear mess, a straight line of chaos. Consider using methods to separate logic and make your code readable.
?
Variable Naming
Your variable names are an insult to the Java language. TextoSemEspacos? Really? How about something descriptive like 'trimmedText'?
+
Magic Numbers
The number 5 in your substring call is a magic number, a curse upon your code. Define a constant or use a more dynamic approach to make your code flexible.
//suggested_fix
original: 40 lines · fixed: 22 lines
TextTorturer_fixed.java
+import java.util.Scanner;
+public class TextTorturer {
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+ System.out.println("Enter a block of text:");
+ String text = scanner.nextLine().trim();
+ System.out.println("Trimmed text: " + text);
+ if (text.length() >= 5) {
+ String subset = text.substring(0, 5);
+ System.out.println("Substring(0,5): " + subset);
+ }
+ String replacedText = text.replace("a", "@");
+ System.out.println("Replaced text: " + replacedText);
+ System.out.println("To upper case: " + text.toUpperCase());
+ System.out.println("To lower case: " + text.toLowerCase());
+ String[] words = text.split(" ");
+ System.out.println("Words separated:");
+ for (String word : words) {
+ System.out.println(word);
+ }
+ }
+}