Commit bad020ac authored by Théo GORDYJAN's avatar Théo GORDYJAN

add_enum

parent 7968a17a
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>
\ No newline at end of file
This diff is collapsed.
......@@ -8,5 +8,4 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</module>
\ No newline at end of file
......@@ -2,7 +2,38 @@ package main;
public enum Brand {
RENAULT,
PEUGEOT,
CITROEN;
RENAULT("Renault"),
PEUGEOT("Peugeot"),
CITROEN("Citroen");
private final String value;
Brand(String value) {
this.value = value;
}
public String getValue() {
return value;
}
/*
public static Brand getEnum(String value) {
for (Brand brand : Brand.values()) {
if (brand.getValue().equals(value)) {
return brand;
}
}
}
*/
public static boolean contains(String value) {
for (Brand brand : Brand.values()) {
if (brand.getValue().equals(value)) {
return true;
}
}
return false;
}
}
package main;
public enum EngineType {
DIESEL("Diesel"),
PETROL("Petrol"),
HYBRID("Hybrid"),
ELECTRIC("Electric");
private final String value;
EngineType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
/*
public static EngineType getEnum(String value) {
for (EngineType type : EngineType.values()) {
if (type.getValue().equals(value)) {
return type;
}
}
}
*/
public static boolean contains(String value) {
for (EngineType type : EngineType.values()) {
if (type.getValue().equals(value)) {
return true;
}
}
return false;
}
}
package main;
public enum engineType {
DIESEL,
PETROL,
HYBRID,
ELECTRIC;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment