├── .gitattributes ├── .github └── dependabot.yml ├── Certification.png ├── LICENSE.md ├── README.md ├── Week 1 Exam - Patients IMC ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── bin │ ├── Main.class │ └── entities │ │ └── Paciente.class └── src │ ├── Main.java │ └── entities │ └── Paciente.java ├── Week 2 Exam - What is the pizza price ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── bin │ ├── CarrinhoDeCompras.class │ ├── Main.class │ └── Pizza.class └── src │ ├── CarrinhoDeCompras.java │ ├── Main.java │ └── Pizza.java ├── Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── Teste │ ├── TesteCarrinhoDeCompras.java │ └── TestePizza.java ├── bin │ ├── CarrinhoDeCompras.class │ ├── Main.class │ ├── Pizza.class │ ├── TesteCarrinhoDeCompras.class │ └── TestePizza.class └── src │ ├── CarrinhoDeCompras.java │ ├── Main.java │ └── Pizza.java ├── Week 4 Exam - Different types of products ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── Tests │ ├── CarrinhoTest.java │ ├── ProdutoTamanhoTest.java │ └── ProdutoTest.java ├── bin │ ├── CarrinhoDeCompras.class │ ├── CarrinhoTest.class │ ├── Produto.class │ ├── ProdutoComTamanho.class │ ├── ProdutoTamanhoTest.class │ └── ProdutoTest.class └── src │ ├── CarrinhoDeCompras.java │ ├── Produto.java │ └── ProdutoComTamanho.java ├── Week 5 Exam - Treatment forms ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── Tests │ └── AutoridadeTest.java ├── bin │ ├── Autoridade.class │ ├── AutoridadeTest.class │ ├── FormatadorNome.class │ ├── NomeComTitulo.class │ ├── NomeInformal.class │ └── NomeRespeitoso.class └── src │ ├── Autoridade.java │ ├── FormatadorNome.java │ ├── NomeComTitulo.java │ ├── NomeInformal.java │ └── NomeRespeitoso.java └── Week 6 Exam - Scrambled Words game ├── .classpath ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── Tests └── EmbaralhadorTest.java ├── bin ├── EmbaralhadorTest.class ├── Main.class ├── dados │ └── BancoDePalavras.class ├── embaralhador │ ├── Embaralhador.class │ ├── EmbaralhadorAleatorio.class │ ├── EmbaralhadorInverso.class │ └── FabricaEmbaralhadores.class └── mecanica │ ├── FabricaMecanicaDoJogo.class │ ├── MecanicaDoJogo.class │ ├── MorteSubita.class │ └── TodasAsPalavras.class ├── palavras.txt └── src ├── Main.java ├── dados └── BancoDePalavras.java ├── embaralhador ├── Embaralhador.java ├── EmbaralhadorAleatorio.java ├── EmbaralhadorInverso.java └── FabricaEmbaralhadores.java └── mecanica ├── FabricaMecanicaDoJogo.java ├── MecanicaDoJogo.java ├── MorteSubita.java └── TodasAsPalavras.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: '/' 5 | schedule: 6 | interval: 'weekly' 7 | -------------------------------------------------------------------------------- /Certification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Certification.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bernardo D'Angelo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Object-Oriented Programming with Java by ITA 2 | Repository for the Object-Oriented Programming with Java course by Instituto Tecnológico de Aeronáutica (ITA). 3 | 4 | [Coursera](https://www.coursera.org/learn/orientacao-a-objetos-com-java/home/info) 5 | 6 | ## About the Course 7 | 8 | The objective of this course is to make you understand the principles of object-oriented programming through the Java language and know how to efficiently apply these principles in practice when designing and developing software in an agile way. The concepts discussed and experimented by you in this course will be the basis for you to be able to understand the new concepts presented in the following courses of this specialization. 9 | 10 | ## Schedule 11 | 12 | #### 1st Module - Classes in Theory and in Java 13 | 14 | In this module, the basic concepts of object-oriented programming will be presented, both in theory and in Java: classes, objects, class attributes, class constructors, responsibilities, collaborations, and CRC cards. 15 | 16 | #### 2nd Module - Java Classes and CRC Modeling 17 | 18 | In this module, there will be a deepening of the previous module, based on classes and methods, as well as CRC modeling. 19 | 20 | Providing the ability to: 21 | 22 | - Model the behavior of classes with methods in Java; 23 | 24 | - Design new classes for an application through CRC modeling. 25 | 26 | #### 3rd Module - Unit Testing, UML Diagrams, Collaboration, and Dependency 27 | 28 | In this module, the concepts of Unit Testing and UML Class Diagrams will be presented, as well as the concepts of dependency and class contract. 29 | 30 | Providing the ability to: 31 | 32 | - Test the behavior of classes in Java with JUnit; 33 | 34 | - Design and represent classes with UML class diagrams. 35 | 36 | #### 4th Module - Inheritance in Theory and in Java 37 | 38 | In this module, the concepts of Inheritance and Access Modifiers will be presented. 39 | 40 | Providing the ability to: 41 | 42 | - Design and structure Java programs based on best practices in the use of inheritance; 43 | 44 | - Ensure low coupling between classes by the proper use of access modifiers. 45 | 46 | #### 5th Module - Encapsulation, Coupling between Classes, and Java Interfaces 47 | 48 | In this module, the concepts of Encapsulation, Coupling between Classes, and Interfaces in Java will be presented. 49 | 50 | Providing the ability to: 51 | 52 | - Design and structure Java programs, avoiding encapsulation breaks and providing low coupling between classes; 53 | 54 | - Ensure abstract coupling between classes through the proper use of interfaces in Java. 55 | 56 | #### 6th Module - Polymorphism, Law of Demeter, and Exceptions in Java 57 | 58 | In this module, the concept of Polymorphism, the "Law of Demeter" principle, and Exceptions in Java will be presented. 59 | 60 | Providing the ability to: 61 | 62 | - Design and structure more flexible and low-coupling Java programs; 63 | 64 | - Ensure proper handling of exceptions in Java. 65 | 66 | ## Certification 67 | 68 | ![Certification](https://github.com/bernardodangelo/object-oriented-java-ita/blob/main/Certification.png) 69 | 70 | ## License 71 | 72 | Licensed under the **MIT**. See [LICENSE](LICENSE.md) for more informations. 73 | 74 | ## Contact 75 | 76 | See my contact information on my [GitHub profile](https://github.com/bernardodangelo). 77 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Week 1 Exam - Patients IMC 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/bin/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 1 Exam - Patients IMC/bin/Main.class -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/bin/entities/Paciente.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 1 Exam - Patients IMC/bin/entities/Paciente.class -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import entities.Paciente; 3 | 4 | public class Main { 5 | 6 | public static void main(String[] args) { 7 | 8 | Scanner sc = new Scanner(System.in); 9 | 10 | Paciente paciente1 = new Paciente(70.5, 1.75); 11 | Paciente paciente2 = new Paciente(90.0, 1.80); 12 | Paciente paciente3 = new Paciente(60.0, 1.60); 13 | 14 | System.out.println("Paciente 1:"); 15 | System.out.println("IMC: " + paciente1.calcularIMC()); 16 | System.out.println("Diagnóstico: " + paciente1.diagnostico()); 17 | 18 | System.out.println(); 19 | 20 | System.out.println("Paciente 2:"); 21 | System.out.println("IMC: " + paciente2.calcularIMC()); 22 | System.out.println("Diagnóstico: " + paciente2.diagnostico()); 23 | 24 | System.out.println(); 25 | 26 | System.out.println("Paciente 3:"); 27 | System.out.println("IMC: " + paciente3.calcularIMC()); 28 | System.out.println("Diagnóstico: " + paciente3.diagnostico()); 29 | 30 | sc.close(); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Week 1 Exam - Patients IMC/src/entities/Paciente.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | public class Paciente { 4 | 5 | private double peso; 6 | private double altura; 7 | 8 | public Paciente(double peso , double altura) { 9 | this.peso = peso; 10 | this.altura = altura; 11 | } 12 | 13 | public double calcularIMC() { 14 | return peso / (altura*altura); 15 | } 16 | 17 | public String diagnostico() { 18 | 19 | if(calcularIMC() < 16) { 20 | return "Baixo peso muito grave"; 21 | } 22 | else if(calcularIMC() < 16.99) { 23 | return "Baixo peso grave"; 24 | } 25 | else if(calcularIMC() < 18.49) { 26 | return "Baixo peso"; 27 | } 28 | else if(calcularIMC() < 24.99) { 29 | return "Peso normal"; 30 | } 31 | else if(calcularIMC() < 29.99) { 32 | return "Sobrepeso"; 33 | } 34 | else if(calcularIMC() < 34.99) { 35 | return "Baixo peso"; 36 | } 37 | else if(calcularIMC() < 39.99) { 38 | return "Baixo peso"; 39 | } 40 | else { 41 | return"Obsidade grau III"; 42 | } 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Week 2 Exam -What is the pizza price 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/bin/CarrinhoDeCompras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 2 Exam - What is the pizza price/bin/CarrinhoDeCompras.class -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/bin/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 2 Exam - What is the pizza price/bin/Main.class -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/bin/Pizza.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 2 Exam - What is the pizza price/bin/Pizza.class -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/src/CarrinhoDeCompras.java: -------------------------------------------------------------------------------- 1 | class CarrinhoDeCompras { 2 | 3 | private int valorTotal; 4 | private int numPizzas; 5 | 6 | public CarrinhoDeCompras() { 7 | valorTotal = 0; 8 | numPizzas = 0; 9 | } 10 | 11 | public void adicionaPizza(Pizza pizza) { 12 | if (pizza.getIngredientes().isEmpty()) { 13 | System.out.println("Erro: pizza sem ingredientes não pode ser adicionada ao carrinho."); 14 | return; 15 | } 16 | 17 | int preco = pizza.getPreco(); 18 | if (preco > 0) { 19 | valorTotal += preco; 20 | numPizzas++; 21 | } 22 | } 23 | 24 | public int getValorTotal() { 25 | return valorTotal; 26 | } 27 | 28 | public int getNumPizzas() { 29 | return numPizzas; 30 | } 31 | } -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | 7 | Pizza pizza1 = new Pizza(); 8 | pizza1.adicionaIngrediente("Queijo"); 9 | pizza1.adicionaIngrediente("Calabresa"); 10 | pizza1.adicionaIngrediente("Cebola"); 11 | 12 | Pizza pizza2 = new Pizza(); 13 | pizza2.adicionaIngrediente("Queijo"); 14 | pizza2.adicionaIngrediente("Chocolate Branco"); 15 | pizza2.adicionaIngrediente("Cholate Preto"); 16 | pizza2.adicionaIngrediente("Granulado"); 17 | 18 | Pizza pizza3 = new Pizza(); 19 | 20 | CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); 21 | carrinho.adicionaPizza(pizza1); 22 | carrinho.adicionaPizza(pizza2); 23 | carrinho.adicionaPizza(pizza3); 24 | 25 | System.out.println("\nQuantidade de pizzas: " + carrinho.getNumPizzas()); 26 | System.out.println("\nValor total: R$ " + carrinho.getValorTotal()); 27 | System.out.println("\nIngredientes utilizados:\n"); 28 | 29 | HashMap ingredientesUtilizados = Pizza.getIngredientesUtilizados(); 30 | 31 | for (String ingrediente : ingredientesUtilizados.keySet()) { 32 | System.out.println(ingrediente + ": " + ingredientesUtilizados.get(ingrediente)); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Week 2 Exam - What is the pizza price/src/Pizza.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class Pizza { 4 | private HashMap ingredientes; 5 | private static HashMap ingredientesUtilizados = new HashMap<>(); 6 | 7 | public Pizza() { 8 | ingredientes = new HashMap<>(); 9 | } 10 | 11 | public void adicionaIngrediente(String ingrediente) { 12 | ingredientes.put(ingrediente, ingredientes.getOrDefault(ingrediente, 0) + 1); 13 | contabilizaIngrediente(ingrediente); 14 | } 15 | 16 | private static void contabilizaIngrediente(String ingrediente) { 17 | ingredientesUtilizados.put(ingrediente, ingredientesUtilizados.getOrDefault(ingrediente, 0) + 1); 18 | } 19 | 20 | public int getPreco() { 21 | int numIngredientes = ingredientes.values().stream().mapToInt(Integer::intValue).sum(); 22 | if (numIngredientes <= 2) { 23 | return 15; 24 | } else if (numIngredientes <= 5) { 25 | return 20; 26 | } else { 27 | return 23; 28 | } 29 | } 30 | 31 | public HashMap getIngredientes() { 32 | return ingredientes; 33 | } 34 | 35 | public static HashMap getIngredientesUtilizados() { 36 | return ingredientesUtilizados; 37 | } 38 | } -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Week 3 Exam -Tests of Pizza and CarrinhoDeCompras classes 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/Teste/TesteCarrinhoDeCompras.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.*; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | public class TesteCarrinhoDeCompras { 7 | 8 | private CarrinhoDeCompras carrinho; 9 | private Pizza pizza1; 10 | private Pizza pizza2; 11 | private Pizza pizza3; 12 | private Pizza pizzaSemIngredientes; 13 | 14 | @Before 15 | public void setUp() { 16 | carrinho = new CarrinhoDeCompras(); 17 | 18 | pizza1 = new Pizza(); 19 | pizza1.adicionaIngrediente("Queijo"); 20 | pizza1.adicionaIngrediente("Calabresa"); 21 | pizza1.adicionaIngrediente("Cebola"); 22 | 23 | pizza2 = new Pizza(); 24 | pizza2.adicionaIngrediente("Queijo"); 25 | pizza2.adicionaIngrediente("Chocolate Branco"); 26 | pizza2.adicionaIngrediente("Chocolate Preto"); 27 | pizza2.adicionaIngrediente("Granulado"); 28 | 29 | pizza3 = new Pizza(); 30 | pizza3.adicionaIngrediente("Queijo"); 31 | pizza3.adicionaIngrediente("Calabresa"); 32 | pizza3.adicionaIngrediente("Tomate"); 33 | pizza3.adicionaIngrediente("Orégano"); 34 | 35 | pizzaSemIngredientes = new Pizza(); 36 | 37 | carrinho.adicionaPizza(pizza1); 38 | carrinho.adicionaPizza(pizza2); 39 | carrinho.adicionaPizza(pizza3); 40 | } 41 | 42 | @Test 43 | public void testValorTotal() { 44 | assertEquals(60, carrinho.getValorTotal()); 45 | } 46 | 47 | @Test 48 | public void testNumPizzas() { 49 | assertEquals(3, carrinho.getNumPizzas()); 50 | } 51 | 52 | @Test 53 | public void testAdicionaPizzaSemIngredientes() { 54 | carrinho.adicionaPizza(pizzaSemIngredientes); 55 | assertEquals(60, carrinho.getValorTotal()); 56 | assertEquals(3, carrinho.getNumPizzas()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/Teste/TestePizza.java: -------------------------------------------------------------------------------- 1 | import static org.junit.jupiter.api.Assertions.assertEquals; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.junit.BeforeClass; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class TestePizza { 9 | 10 | @BeforeClass 11 | public static void zeraIngredientesUtilizados() { 12 | Pizza.zeraIngredientesUtilizados(); 13 | } 14 | 15 | @Test 16 | void testPrecoDoisIngredientes() { 17 | Pizza pizza = new Pizza(); 18 | pizza.adicionaIngrediente("Queijo"); 19 | pizza.adicionaIngrediente("Calabresa"); 20 | assertEquals(15, pizza.getPreco()); 21 | } 22 | 23 | @Test 24 | void testPrecoCincoIngredientes() { 25 | Pizza pizza = new Pizza(); 26 | pizza.adicionaIngrediente("Queijo"); 27 | pizza.adicionaIngrediente("Chocolate Branco"); 28 | pizza.adicionaIngrediente("Cholate Preto"); 29 | pizza.adicionaIngrediente("Coco"); 30 | pizza.adicionaIngrediente("Granulado"); 31 | assertEquals(20, pizza.getPreco()); 32 | } 33 | 34 | @Test 35 | void testPrecoMaisDeCincoIngredientes() { 36 | Pizza pizza = new Pizza(); 37 | pizza.adicionaIngrediente("Queijo"); 38 | pizza.adicionaIngrediente("Ovo"); 39 | pizza.adicionaIngrediente("Azeitona"); 40 | pizza.adicionaIngrediente("Cebola"); 41 | pizza.adicionaIngrediente("Ervilha"); 42 | pizza.adicionaIngrediente("Azeite"); 43 | assertEquals(23, pizza.getPreco()); 44 | } 45 | 46 | 47 | @Test 48 | void testGetIngredientesUtilizados() { 49 | Pizza pizza = new Pizza(); 50 | pizza.adicionaIngrediente("Queijo"); 51 | pizza.adicionaIngrediente("Calabresa"); 52 | HashMap ingredientesUtilizados = Pizza.getIngredientesUtilizados(); 53 | assertEquals(1, (int) ingredientesUtilizados.get("Queijo")); 54 | assertEquals(1, (int) ingredientesUtilizados.get("Calabresa")); 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/CarrinhoDeCompras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/CarrinhoDeCompras.class -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/Main.class -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/Pizza.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/Pizza.class -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/TesteCarrinhoDeCompras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/TesteCarrinhoDeCompras.class -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/TestePizza.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/bin/TestePizza.class -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/src/CarrinhoDeCompras.java: -------------------------------------------------------------------------------- 1 | class CarrinhoDeCompras { 2 | 3 | private int valorTotal; 4 | private int numPizzas; 5 | 6 | public CarrinhoDeCompras() { 7 | valorTotal = 0; 8 | numPizzas = 0; 9 | } 10 | 11 | public void adicionaPizza(Pizza pizza) { 12 | if (pizza.getIngredientes().isEmpty()) { 13 | System.out.println("Erro: pizza sem ingredientes não pode ser adicionada ao carrinho."); 14 | return; 15 | } 16 | 17 | int preco = pizza.getPreco(); 18 | if (preco > 0) { 19 | valorTotal += preco; 20 | numPizzas++; 21 | } 22 | } 23 | 24 | public int getValorTotal() { 25 | return valorTotal; 26 | } 27 | 28 | public int getNumPizzas() { 29 | return numPizzas; 30 | } 31 | } -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | 7 | Pizza pizza1 = new Pizza(); 8 | pizza1.adicionaIngrediente("Queijo"); 9 | pizza1.adicionaIngrediente("Calabresa"); 10 | pizza1.adicionaIngrediente("Cebola"); 11 | 12 | Pizza pizza2 = new Pizza(); 13 | pizza2.adicionaIngrediente("Queijo"); 14 | pizza2.adicionaIngrediente("Chocolate Branco"); 15 | pizza2.adicionaIngrediente("Cholate Preto"); 16 | pizza2.adicionaIngrediente("Granulado"); 17 | 18 | Pizza pizza3 = new Pizza(); 19 | 20 | 21 | CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); 22 | carrinho.adicionaPizza(pizza1); 23 | carrinho.adicionaPizza(pizza2); 24 | carrinho.adicionaPizza(pizza3); 25 | 26 | System.out.println("\nQuantidade de pizzas: " + carrinho.getNumPizzas()); 27 | System.out.println("\nValor total: R$ " + carrinho.getValorTotal()); 28 | System.out.println("\nIngredientes utilizados:\n"); 29 | 30 | HashMap ingredientesUtilizados = Pizza.getIngredientesUtilizados(); 31 | 32 | for (String ingrediente : ingredientesUtilizados.keySet()) { 33 | System.out.println(ingrediente + ": " + ingredientesUtilizados.get(ingrediente)); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Week 3 Exam - Tests of Pizza and CarrinhoDeCompras classes/src/Pizza.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | 3 | public class Pizza { 4 | private HashMap ingredientes; 5 | private static HashMap ingredientesUtilizados = new HashMap<>(); 6 | 7 | public Pizza() { 8 | ingredientes = new HashMap<>(); 9 | } 10 | 11 | public void adicionaIngrediente(String ingrediente) { 12 | ingredientes.put(ingrediente, ingredientes.getOrDefault(ingrediente, 0) + 1); 13 | contabilizaIngrediente(ingrediente); 14 | } 15 | 16 | private static void contabilizaIngrediente(String ingrediente) { 17 | ingredientesUtilizados.put(ingrediente, ingredientesUtilizados.getOrDefault(ingrediente, 0) + 1); 18 | } 19 | 20 | public int getPreco() { 21 | int numIngredientes = ingredientes.values().stream().mapToInt(Integer::intValue).sum(); 22 | if (numIngredientes <= 2) { 23 | return 15; 24 | } else if (numIngredientes <= 5) { 25 | return 20; 26 | } else { 27 | return 23; 28 | } 29 | } 30 | 31 | public HashMap getIngredientes() { 32 | return ingredientes; 33 | } 34 | 35 | public static HashMap getIngredientesUtilizados() { 36 | return ingredientesUtilizados; 37 | } 38 | 39 | public static void zeraIngredientesUtilizados() { 40 | ingredientesUtilizados.clear(); 41 | } 42 | } -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Week 4 - Different types of products 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/Tests/CarrinhoTest.java: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.Test; 2 | import static org.junit.jupiter.api.Assertions.*; 3 | 4 | public class CarrinhoTest { 5 | 6 | @Test 7 | public void testAdicionaProduto() { 8 | CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); 9 | Produto produto1 = new Produto("Produto 1", 1, 10.0); 10 | Produto produto2 = new Produto("Produto 2", 2, 20.0); 11 | 12 | carrinho.adicionaProduto(produto1, 2); 13 | carrinho.adicionaProduto(produto2, 3); 14 | 15 | assertEquals(2, carrinho.getQuantidadeProduto(produto1)); 16 | assertEquals(3, carrinho.getQuantidadeProduto(produto2)); 17 | } 18 | 19 | @Test 20 | public void testRemoveProduto() { 21 | CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); 22 | Produto produto1 = new Produto("Produto 1", 1, 10.0); 23 | Produto produto2 = new Produto("Produto 2", 2, 20.0); 24 | 25 | carrinho.adicionaProduto(produto1, 2); 26 | carrinho.adicionaProduto(produto2, 3); 27 | carrinho.removeProduto(produto1, 1); 28 | 29 | assertEquals(1, carrinho.getQuantidadeProduto(produto1)); 30 | assertEquals(3, carrinho.getQuantidadeProduto(produto2)); 31 | } 32 | 33 | @Test 34 | public void testCalcularValorTotal() { 35 | CarrinhoDeCompras carrinho = new CarrinhoDeCompras(); 36 | Produto produto1 = new Produto("Produto 1", 1, 10.0); 37 | Produto produto2 = new Produto("Produto 2", 2, 20.0); 38 | 39 | carrinho.adicionaProduto(produto1, 2); 40 | carrinho.adicionaProduto(produto2, 3); 41 | 42 | assertEquals(80.0, carrinho.calcularValorTotal()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/Tests/ProdutoTamanhoTest.java: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.Test; 2 | import static org.junit.jupiter.api.Assertions.*; 3 | 4 | public class ProdutoTamanhoTest { 5 | 6 | @Test 7 | public void testEquals() { 8 | ProdutoComTamanho produto1 = new ProdutoComTamanho("Produto 1", 1, 20.0, "P"); 9 | ProdutoComTamanho produto2 = new ProdutoComTamanho("Produto 2", 1, 10.0, "P"); 10 | ProdutoComTamanho produto3 = new ProdutoComTamanho("Produto 3", 2, 30.0, "G"); 11 | 12 | assertTrue(produto1.equals(produto2)); 13 | assertFalse(produto1.equals(produto3)); 14 | } 15 | 16 | @Test 17 | public void testHashCode() { 18 | ProdutoComTamanho produto1 = new ProdutoComTamanho("Produto 1", 1, 20.0, "P"); 19 | ProdutoComTamanho produto2 = new ProdutoComTamanho("Produto 2", 1, 10.0, "P"); 20 | 21 | assertEquals(produto1.hashCode(), produto2.hashCode()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/Tests/ProdutoTest.java: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.Test; 2 | import static org.junit.jupiter.api.Assertions.*; 3 | 4 | public class ProdutoTest { 5 | 6 | @Test 7 | public void testEquals() { 8 | Produto produto1 = new Produto("Produto 1", 1, 10.0); 9 | Produto produto2 = new Produto("Produto 2", 1, 20.0); 10 | Produto produto3 = new Produto("Produto 3", 2, 30.0); 11 | 12 | assertTrue(produto1.equals(produto2)); 13 | assertFalse(produto1.equals(produto3)); 14 | } 15 | 16 | @Test 17 | public void testHashCode() { 18 | Produto produto1 = new Produto("Produto 1", 1, 10.0); 19 | Produto produto2 = new Produto("Produto 2", 1, 20.0); 20 | 21 | assertEquals(produto1.hashCode(), produto2.hashCode()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/CarrinhoDeCompras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/CarrinhoDeCompras.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/CarrinhoTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/CarrinhoTest.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/Produto.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/Produto.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/ProdutoComTamanho.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/ProdutoComTamanho.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/ProdutoTamanhoTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/ProdutoTamanhoTest.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/bin/ProdutoTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 4 Exam - Different types of products/bin/ProdutoTest.class -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/src/CarrinhoDeCompras.java: -------------------------------------------------------------------------------- 1 | import java.util.HashMap; 2 | import java.util.Map; 3 | 4 | public class CarrinhoDeCompras { 5 | private Map produtos; 6 | 7 | public CarrinhoDeCompras() { 8 | produtos = new HashMap<>(); 9 | } 10 | 11 | public void adicionaProduto(Produto produto, int quantidade) { 12 | if (produtos.containsKey(produto)) { 13 | int quantidadeAtual = produtos.get(produto); 14 | produtos.put(produto, quantidadeAtual + quantidade); 15 | } else { 16 | produtos.put(produto, quantidade); 17 | } 18 | } 19 | 20 | public void removeProduto(Produto produto, int quantidade) { 21 | if (produtos.containsKey(produto)) { 22 | int quantidadeAtual = produtos.get(produto); 23 | if (quantidade <= quantidadeAtual) { 24 | int novaQuantidade = quantidadeAtual - quantidade; 25 | if (novaQuantidade > 0) { 26 | produtos.put(produto, novaQuantidade); 27 | } else { 28 | produtos.remove(produto); 29 | } 30 | } 31 | } 32 | } 33 | 34 | public double calcularValorTotal() { 35 | double valorTotal = 0; 36 | for (Map.Entry entry : produtos.entrySet()) { 37 | Produto produto = entry.getKey(); 38 | int quantidade = entry.getValue(); 39 | valorTotal += produto.getPreco() * quantidade; 40 | } 41 | return valorTotal; 42 | } 43 | 44 | public int getQuantidadeProduto(Produto produto) { 45 | return produtos.getOrDefault(produto, 0); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/src/Produto.java: -------------------------------------------------------------------------------- 1 | import java.util.Objects; 2 | 3 | public class Produto { 4 | private String nome; 5 | private int codigo; 6 | private double preco; 7 | 8 | public Produto(String nome, int codigo, double preco) { 9 | this.nome = nome; 10 | this.codigo = codigo; 11 | this.preco = preco; 12 | } 13 | 14 | public String getNome() { 15 | return nome; 16 | } 17 | 18 | public int getCodigo() { 19 | return codigo; 20 | } 21 | 22 | public double getPreco() { 23 | return preco; 24 | } 25 | 26 | public boolean equals(Object o) { 27 | if (this == o) return true; 28 | if (o == null || getClass() != o.getClass()) return false; 29 | Produto produto = (Produto) o; 30 | return codigo == produto.codigo; 31 | } 32 | 33 | public int hashCode() { 34 | return Objects.hash(codigo); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Week 4 Exam - Different types of products/src/ProdutoComTamanho.java: -------------------------------------------------------------------------------- 1 | import java.util.Objects; 2 | 3 | public class ProdutoComTamanho extends Produto { 4 | private String tamanho; 5 | 6 | public ProdutoComTamanho(String nome, int codigo, double preco, String tamanho) { 7 | super(nome, codigo, preco); 8 | this.tamanho = tamanho; 9 | } 10 | 11 | public String getTamanho() { 12 | return tamanho; 13 | } 14 | 15 | public boolean equals(Object o) { 16 | if (this == o) return true; 17 | if (o == null || getClass() != o.getClass()) return false; 18 | if (!super.equals(o)) return false; 19 | ProdutoComTamanho produto = (ProdutoComTamanho) o; 20 | return Objects.equals(tamanho, produto.tamanho); 21 | } 22 | 23 | public int hashCode() { 24 | return Objects.hash(super.hashCode(), tamanho); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Week 5 Exam - Treatment forms 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/Tests/AutoridadeTest.java: -------------------------------------------------------------------------------- 1 | import static org.junit.jupiter.api.Assertions.assertEquals; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | class AutoridadeTest { 6 | 7 | @Test 8 | void testFormatarNomeInformal() { 9 | Autoridade autoridade = new Autoridade("Bernardo", "D'Angelo", new NomeInformal()); 10 | assertEquals("Bernardo", autoridade.getTratamento()); 11 | } 12 | 13 | @Test 14 | void testFormatarNomeRespeitosoMasculino() { 15 | Autoridade autoridade = new Autoridade("Bernardo", "D'Angelo", new NomeRespeitoso("Masculino")); 16 | assertEquals("Sr. D'Angelo", autoridade.getTratamento()); 17 | } 18 | 19 | @Test 20 | void testFormatarNomeRespeitosoFeminino() { 21 | Autoridade autoridade = new Autoridade("Anastásia", "D'Angelo", new NomeRespeitoso("Feminino")); 22 | assertEquals("Sra. D'Angelo", autoridade.getTratamento()); 23 | } 24 | 25 | @Test 26 | void testFormatarNomeComTitulo() { 27 | Autoridade autoridade = new Autoridade("Bernardo", "D'Angelo", new NomeComTitulo("Magnífico")); 28 | assertEquals("Magnífico Bernardo D'Angelo", autoridade.getTratamento()); 29 | } 30 | } -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/Autoridade.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/Autoridade.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/AutoridadeTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/AutoridadeTest.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/FormatadorNome.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/FormatadorNome.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/NomeComTitulo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/NomeComTitulo.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/NomeInformal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/NomeInformal.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/bin/NomeRespeitoso.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 5 Exam - Treatment forms/bin/NomeRespeitoso.class -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/src/Autoridade.java: -------------------------------------------------------------------------------- 1 | 2 | public class Autoridade { 3 | 4 | private String nome; 5 | private String sobrenome; 6 | private FormatadorNome formatadorNome; 7 | 8 | 9 | public Autoridade(String nome, String sobrenome, FormatadorNome formatadorNome) { 10 | this.nome = nome; 11 | this.sobrenome = sobrenome; 12 | this.formatadorNome = formatadorNome; 13 | } 14 | 15 | public String getTratamento() { 16 | return formatadorNome.formatarNome(nome, sobrenome); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/src/FormatadorNome.java: -------------------------------------------------------------------------------- 1 | 2 | public interface FormatadorNome { 3 | 4 | String formatarNome(String nome, String sobrenome); 5 | 6 | } 7 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/src/NomeComTitulo.java: -------------------------------------------------------------------------------- 1 | 2 | public class NomeComTitulo implements FormatadorNome{ 3 | private String titulo; 4 | 5 | public NomeComTitulo(String titulo) { 6 | this.titulo = titulo; 7 | } 8 | 9 | 10 | public String formatarNome(String nome, String sobrenome) { 11 | return titulo + " " + nome + " " + sobrenome; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/src/NomeInformal.java: -------------------------------------------------------------------------------- 1 | 2 | public class NomeInformal implements FormatadorNome { 3 | 4 | public String formatarNome(String nome, String sobrenome) { 5 | return nome; 6 | } 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Week 5 Exam - Treatment forms/src/NomeRespeitoso.java: -------------------------------------------------------------------------------- 1 | 2 | public class NomeRespeitoso implements FormatadorNome { 3 | 4 | private String genero; 5 | 6 | public NomeRespeitoso(String genero) { 7 | this.genero = genero; 8 | } 9 | 10 | public String formatarNome(String nome, String sobrenome) { 11 | if(genero.equals("Masculino")) { 12 | return "Sr. " + sobrenome; 13 | }else if(genero.equals("Feminino")){ 14 | return "Sra. " + sobrenome; 15 | }else { 16 | return "Gênero inválido"; 17 | } 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | week 7 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=17 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=17 15 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/Tests/EmbaralhadorTest.java: -------------------------------------------------------------------------------- 1 | import org.junit.Assert; 2 | import org.junit.Test; 3 | 4 | import embaralhador.EmbaralhadorAleatorio; 5 | import embaralhador.EmbaralhadorInverso; 6 | 7 | public class EmbaralhadorTest { 8 | 9 | @Test 10 | public void testAleatorio() { 11 | EmbaralhadorAleatorio embaralhador = new EmbaralhadorAleatorio(); 12 | 13 | String palavra = "LIMONADA"; 14 | String embaralhado = embaralhador.embaralhar(palavra); 15 | 16 | Assert.assertNotEquals(palavra, embaralhado); 17 | Assert.assertEquals(palavra.length(), embaralhado.length()); 18 | for (char c : palavra.toCharArray()) { 19 | Assert.assertTrue(embaralhado.contains(String.valueOf(c))); 20 | } 21 | } 22 | 23 | @Test 24 | public void testInverso() { 25 | EmbaralhadorInverso embaralhador = new EmbaralhadorInverso(); 26 | 27 | String palavra = "LIMONADA"; 28 | String embaralhado = embaralhador.embaralhar(palavra); 29 | 30 | Assert.assertEquals("ADANOMIL", embaralhado); 31 | } 32 | } -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/EmbaralhadorTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/EmbaralhadorTest.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/Main.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/dados/BancoDePalavras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/dados/BancoDePalavras.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/embaralhador/Embaralhador.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/embaralhador/Embaralhador.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/embaralhador/EmbaralhadorAleatorio.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/embaralhador/EmbaralhadorAleatorio.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/embaralhador/EmbaralhadorInverso.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/embaralhador/EmbaralhadorInverso.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/embaralhador/FabricaEmbaralhadores.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/embaralhador/FabricaEmbaralhadores.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/mecanica/FabricaMecanicaDoJogo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/mecanica/FabricaMecanicaDoJogo.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/mecanica/MecanicaDoJogo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/mecanica/MecanicaDoJogo.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/mecanica/MorteSubita.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/mecanica/MorteSubita.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/bin/mecanica/TodasAsPalavras.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernardodangelo/object-oriented-programming-ita/2a6ddd4d4a1de8360407dbb79779a1ff79b2df2a/Week 6 Exam - Scrambled Words game/bin/mecanica/TodasAsPalavras.class -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/palavras.txt: -------------------------------------------------------------------------------- 1 | CASA 2 | ÁGUA 3 | SUCO 4 | FERRO 5 | COBRE 6 | PEIXE 7 | BALDE 8 | PEDRA 9 | CARVÃO 10 | CASUAL 11 | TEORIA 12 | TRIVIAL 13 | COLOSSO 14 | EXÓTICO 15 | LIMONADA 16 | SINTONIA 17 | NOSTALGIA 18 | ARMADILHA 19 | EXCELÊNCIA 20 | RETRÓGRADO -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | import dados.BancoDePalavras; 4 | import embaralhador.Embaralhador; 5 | import mecanica.FabricaMecanicaDoJogo; 6 | import mecanica.MecanicaDoJogo; 7 | 8 | public class Main { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | FabricaMecanicaDoJogo fabricaMecanica = new FabricaMecanicaDoJogo(); 12 | BancoDePalavras bancoDePalavras = new BancoDePalavras("palavras.txt"); 13 | 14 | System.out.println("Bem-vindo ao Jogo das Palavras Embaralhadas"); 15 | System.out.println(""); 16 | System.out.println("- Escolha uma mecânica de jogo -"); 17 | System.out.println("(1) - Morte súbita"); 18 | System.out.println("(2) - Pontuação máxima"); 19 | System.out.println("Digite o seu determinado número para selecioná-la: "); 20 | int modo = sc.nextInt(); 21 | sc.nextLine(); 22 | 23 | MecanicaDoJogo mecanicaDoJogo = fabricaMecanica.criarMecanicaDoJogo(modo); 24 | Embaralhador embaralhador = fabricaMecanica.criarEmbaralhador(); 25 | 26 | while (!mecanicaDoJogo.isFimDeJogo()) { 27 | String palavra = bancoDePalavras.getPalavraAleatoria(); 28 | if (palavra == null) { 29 | System.out.println(""); 30 | System.out.println("Não há mais palavras disponíveis."); 31 | break; 32 | } 33 | 34 | String palavraEmbaralhada = embaralhador.embaralhar(palavra); 35 | 36 | System.out.println(""); 37 | System.out.println("Palavra embaralhada: " + palavraEmbaralhada); 38 | System.out.print("Digite sua tentativa: "); 39 | String tentativa = sc.nextLine(); 40 | 41 | if (mecanicaDoJogo.verificarPalavra(palavra, tentativa)) { 42 | System.out.println(""); 43 | System.out.println("Parabéns! Você acertou."); 44 | } else { 45 | System.out.println("Você errou."); 46 | } 47 | } 48 | 49 | int pontuacaoFinal = mecanicaDoJogo.getPontuacao(); 50 | 51 | System.out.println(""); 52 | System.out.println("Pontuação final: " + pontuacaoFinal); 53 | 54 | sc.close(); 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/dados/BancoDePalavras.java: -------------------------------------------------------------------------------- 1 | package dados; 2 | 3 | import java.io.File; 4 | import java.io.FileNotFoundException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Random; 8 | import java.util.Scanner; 9 | 10 | public class BancoDePalavras { 11 | private List palavras; 12 | 13 | public BancoDePalavras(String arquivo) { 14 | palavras = new ArrayList<>(); 15 | lerPalavrasDoArquivo(arquivo); 16 | } 17 | 18 | private void lerPalavrasDoArquivo(String arquivo) { 19 | try (Scanner scanner = new Scanner(new File(arquivo))) { 20 | while (scanner.hasNextLine()) { 21 | String palavra = scanner.nextLine(); 22 | palavras.add(palavra); 23 | } 24 | } catch (FileNotFoundException e) { 25 | System.out.println("Erro ao ler o arquivo de palavras: " + arquivo); 26 | } 27 | } 28 | 29 | public String getPalavraAleatoria() { 30 | if (palavras.isEmpty()) { 31 | return null; 32 | } 33 | 34 | Random random = new Random(); 35 | int indice = random.nextInt(palavras.size()); 36 | return palavras.remove(indice); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/embaralhador/Embaralhador.java: -------------------------------------------------------------------------------- 1 | package embaralhador; 2 | 3 | public interface Embaralhador { 4 | String embaralhar(String palavra); 5 | } 6 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/embaralhador/EmbaralhadorAleatorio.java: -------------------------------------------------------------------------------- 1 | package embaralhador; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class EmbaralhadorAleatorio implements Embaralhador { 8 | 9 | public String embaralhar(String palavra) { 10 | List caracteres = new ArrayList<>(); 11 | for (char c : palavra.toCharArray()) { 12 | caracteres.add(c); 13 | } 14 | Collections.shuffle(caracteres); 15 | StringBuilder embaralhado = new StringBuilder(); 16 | for (char c : caracteres) { 17 | embaralhado.append(c); 18 | } 19 | return embaralhado.toString(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/embaralhador/EmbaralhadorInverso.java: -------------------------------------------------------------------------------- 1 | package embaralhador; 2 | 3 | public class EmbaralhadorInverso implements Embaralhador { 4 | 5 | public String embaralhar(String palavra) { 6 | return new StringBuilder(palavra).reverse().toString(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/embaralhador/FabricaEmbaralhadores.java: -------------------------------------------------------------------------------- 1 | package embaralhador; 2 | 3 | import java.util.Random; 4 | 5 | public class FabricaEmbaralhadores { 6 | private Random random; 7 | 8 | public FabricaEmbaralhadores() { 9 | random = new Random(); 10 | } 11 | 12 | public Embaralhador obterEmbaralhadorAleatorio() { 13 | int escolha = random.nextInt(2); 14 | 15 | if (escolha == 0) { 16 | return new EmbaralhadorAleatorio(); 17 | } else { 18 | return new EmbaralhadorInverso(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/mecanica/FabricaMecanicaDoJogo.java: -------------------------------------------------------------------------------- 1 | package mecanica; 2 | 3 | import embaralhador.Embaralhador; 4 | import embaralhador.FabricaEmbaralhadores; 5 | 6 | public class FabricaMecanicaDoJogo { 7 | 8 | public MecanicaDoJogo criarMecanicaDoJogo(int modo) { 9 | if (modo == 1) { 10 | return new MorteSubita(); 11 | } else if (modo == 2) { 12 | return new TodasAsPalavras(); 13 | } else { 14 | throw new IllegalArgumentException("Modo de jogo inválido"); 15 | } 16 | } 17 | 18 | public Embaralhador criarEmbaralhador() { 19 | FabricaEmbaralhadores fabricaEmbaralhadores = new FabricaEmbaralhadores(); 20 | return fabricaEmbaralhadores.obterEmbaralhadorAleatorio(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/mecanica/MecanicaDoJogo.java: -------------------------------------------------------------------------------- 1 | package mecanica; 2 | 3 | public interface MecanicaDoJogo { 4 | 5 | boolean isFimDeJogo(); 6 | 7 | boolean verificarPalavra(String palavraCorreta, String tentativa); 8 | 9 | int getPontuacao(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/mecanica/MorteSubita.java: -------------------------------------------------------------------------------- 1 | package mecanica; 2 | 3 | public class MorteSubita implements MecanicaDoJogo { 4 | private int pontuacao; 5 | private int tentativas; 6 | private boolean acertou; 7 | 8 | public MorteSubita() { 9 | pontuacao = 0; 10 | tentativas = 0; 11 | acertou = true; 12 | } 13 | 14 | public boolean isFimDeJogo() { 15 | return tentativas > 0 && !acertou; 16 | } 17 | 18 | public boolean verificarPalavra(String palavraCorreta, String tentativa) { 19 | tentativas++; 20 | acertou = palavraCorreta.equalsIgnoreCase(tentativa); 21 | if (acertou) { 22 | pontuacao++; 23 | } 24 | return acertou; 25 | } 26 | 27 | @Override 28 | public int getPontuacao() { 29 | return pontuacao; 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Week 6 Exam - Scrambled Words game/src/mecanica/TodasAsPalavras.java: -------------------------------------------------------------------------------- 1 | package mecanica; 2 | 3 | public class TodasAsPalavras implements MecanicaDoJogo { 4 | private static final int MAX_PALAVRAS = 20; 5 | private int pontuacao; 6 | private int palavraAtual; 7 | 8 | public TodasAsPalavras() { 9 | pontuacao = 0; 10 | palavraAtual = 0; 11 | } 12 | 13 | public boolean isFimDeJogo() { 14 | return palavraAtual >= MAX_PALAVRAS; 15 | } 16 | 17 | public boolean verificarPalavra(String palavraCorreta, String tentativa) { 18 | boolean acertou = palavraCorreta.equalsIgnoreCase(tentativa); 19 | if (acertou) { 20 | pontuacao++; 21 | } 22 | palavraAtual++; 23 | return acertou; 24 | } 25 | 26 | public int getPontuacao() { 27 | return pontuacao; 28 | } 29 | } 30 | 31 | --------------------------------------------------------------------------------