This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum TipoJogo { | |
ACAO("Ação"), AVENTURA("Aventura"), RPG("Role-playing game"); | |
private String descricao; | |
private TipoJogo(String descricao) { | |
this.descricao = descricao; | |
} | |
public String getDescricao() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TiposJogosComSwitch | |
{ | |
public enum TipoJogo | |
{ | |
ACAO, AVENTURA, RPG | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TiposJogosComSwitch | |
{ | |
public static class TipoJogoDescricao | |
{ | |
public static string GetDescricao(this TipoJogo tipoJogo) | |
{ | |
switch (tipoJogo) | |
{ | |
case TipoJogo.ACAO: | |
return "Ação"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TiposJogosComSwitch | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
TipoJogo tipoJogo = TipoJogo.RPG; | |
Console.WriteLine(tipoJogo.GetDescricao()); | |
// No console --> Role-playing game |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace TiposJogosComAtributo.Atributos | |
{ | |
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] | |
public class Descricao : Attribute | |
{ | |
public string Valor { get; private set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using TiposJogosComAtributo.Atributos; | |
namespace TiposJogosComAtributo | |
{ | |
public enum TipoJogo | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.testes.spring.maven</groupId> | |
<artifactId>simples</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>war</packaging> | |
<build> | |
<sourceDirectory>src</sourceDirectory> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.testes.spring.maven.simples.config; | |
import org.springframework.context.annotation.ComponentScan; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
@Configuration // Faz o Spring mapear essa classe | |
@ComponentScan("com.testes.spring.maven.simples") // Indica onde o Spring deve procurar novos componentes | |
@EnableWebMvc // Ativa o suporte básico do Spring para uma aplicação MVC. Ele, por exemplo, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" | |
id="WebApp_ID" version="4.0"> | |
<display-name>com.testes.spring.maven.simples</display-name> | |
<servlet> | |
<servlet-name>springDispatcherServlet</servlet-name> | |
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ************************* Dependências do Mongo ************************* --> | |
<!-- Spring Data Mongo: tem classes e interfaces que nos permite conectar | |
ao MongoDB --> | |
<dependency> | |
<groupId>org.springframework.data</groupId> | |
<artifactId>spring-data-mongodb</artifactId> | |
<version>2.2.4.RELEASE</version> | |
</dependency> |
OlderNewer