errors
This commit is contained in:
23
.idea/workspace.xml
generated
23
.idea/workspace.xml
generated
@@ -5,14 +5,13 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="12bd6c53-8ba7-454c-a61e-7a76cc3b801b" name="Changes" comment="">
|
<list default="true" id="12bd6c53-8ba7-454c-a61e-7a76cc3b801b" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/cartailor.iml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/fr/impl/CategoryImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/CategoryImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/CategoryImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/CategoryImpl.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/CompatibilityCheckerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/CompatibilityCheckerImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/fr/impl/CompatibilityManagerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/CompatibilityManagerImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/CompatibilityManagerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/CompatibilityManagerImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/fr/impl/ConfigurationImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/ConfigurationImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/ConfigurationImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/ConfigurationImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/fr/impl/ConfiguratorImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/ConfiguratorImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/ConfiguratorImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/ConfiguratorImpl.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/PartImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/PartImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/fr/impl/PartTypeImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/PartTypeImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/fr/impl/PartTypeImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/fr/impl/PartTypeImpl.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@@ -46,7 +45,7 @@
|
|||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"git-widget-placeholder": "dev__v1",
|
"git-widget-placeholder": "dev__v2",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Users/vumin/Desktop/M1/ALO/cartailor",
|
"last_opened_file_path": "C:/Users/vumin/Desktop/M1/ALO/cartailor",
|
||||||
@@ -68,21 +67,6 @@
|
|||||||
<recent name="C:\Users\vumin\Desktop\M1\ALO\cartailor" />
|
<recent name="C:\Users\vumin\Desktop\M1\ALO\cartailor" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
|
||||||
<configuration default="true" type="JetRunConfigurationType">
|
|
||||||
<module name="cartailor" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
|
|
||||||
<module name="cartailor" />
|
|
||||||
<option name="filePath" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
<attachedChunks>
|
<attachedChunks>
|
||||||
<set>
|
<set>
|
||||||
@@ -105,6 +89,7 @@
|
|||||||
<workItem from="1729743145740" duration="122000" />
|
<workItem from="1729743145740" duration="122000" />
|
||||||
<workItem from="1729757559608" duration="166000" />
|
<workItem from="1729757559608" duration="166000" />
|
||||||
<workItem from="1729764402753" duration="206000" />
|
<workItem from="1729764402753" duration="206000" />
|
||||||
|
<workItem from="1731196687641" duration="82000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package src.fr.impl;
|
package src.fr.impl;
|
||||||
|
|
||||||
|
import src.fr.api.Category;
|
||||||
|
|
||||||
public class CategoryImpl implements src.fr.api.Category {
|
public class CategoryImpl implements Category {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public CategoryImpl(String name){
|
public CategoryImpl(String name){
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ package src.fr.impl;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
|
import src.fr.api.CompatibilityChecker;
|
||||||
|
|
||||||
|
|
||||||
public class CompatibilityCheckerImpl implements src.fr.api.CompatibilityChecker {
|
public class CompatibilityCheckerImpl implements CompatibilityChecker {
|
||||||
|
|
||||||
private HashMap<PartType, Set<PartType>> incompatibilities;
|
private HashMap<PartType, Set<PartType>> incompatibilities;
|
||||||
private HashMap<PartType, Set<PartType>> requirements;
|
private HashMap<PartType, Set<PartType>> requirements;
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
|
import src.fr.api.CompatibilityManager;
|
||||||
|
|
||||||
public class CompatibilityManagerImpl implements src.fr.api.CompatibilityManager {
|
public class CompatibilityManagerImpl implements CompatibilityManager {
|
||||||
|
|
||||||
private HashMap<PartType, Set<PartType>> incompatibilities;
|
private HashMap<PartType, Set<PartType>> incompatibilities;
|
||||||
private HashMap<PartType, Set<PartType>> requirements;
|
private HashMap<PartType, Set<PartType>> requirements;
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package src.fr.impl;
|
|||||||
import src.fr.api.Category;
|
import src.fr.api.Category;
|
||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
import src.fr.api.CompatibilityManager;
|
import src.fr.api.CompatibilityManager;
|
||||||
|
import src.fr.api.Configuration;
|
||||||
import src.fr.api.Part;
|
import src.fr.api.Part;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ConfigurationImpl implements src.fr.api.Configuration {
|
public class ConfigurationImpl implements Configuration {
|
||||||
private Set<PartType> selectedParts;
|
private Set<Part> selectedParts;
|
||||||
private CompatibilityManager compatibilityManager;
|
private CompatibilityManager compatibilityManager;
|
||||||
private static int NB_CATEGORY = 4;
|
private static int NB_CATEGORY = 4;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ public class ConfigurationImpl implements src.fr.api.Configuration {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if (this.isComplete()){
|
if (this.isComplete()){
|
||||||
for(PartType pt: selectedParts){
|
for(Part pt: selectedParts){
|
||||||
//Verifier Requirements
|
//Verifier Requirements
|
||||||
for(PartType require : compatibilityManager.getRequirements(pt)){
|
for(PartType require : compatibilityManager.getRequirements(pt)){
|
||||||
if(!selectedParts.contains(require)) return false;
|
if(!selectedParts.contains(require)) return false;
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package src.fr.impl;
|
|||||||
import src.fr.api.Category;
|
import src.fr.api.Category;
|
||||||
import src.fr.api.CompatibilityChecker;
|
import src.fr.api.CompatibilityChecker;
|
||||||
import src.fr.api.Configuration;
|
import src.fr.api.Configuration;
|
||||||
|
import src.fr.api.Configurator;
|
||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ConfiguratorImpl implements src.fr.api.Configurator {
|
public class ConfiguratorImpl implements Configurator {
|
||||||
private Set<Category> categories;
|
private Set<Category> categories;
|
||||||
private Set<PartType> partTypes;
|
private Set<PartType> partTypes;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|||||||
@@ -1,37 +1,79 @@
|
|||||||
package src.fr.impl;
|
package src.fr.impl;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import src.fr.api.Part;
|
||||||
import src.fr.api.Category;
|
import src.fr.api.Category;
|
||||||
import src.fr.api.PartType;
|
import src.fr.api.PartType;
|
||||||
|
|
||||||
public class PartImpl implements src.fr.api.Part {
|
public class PartImpl implements Part {
|
||||||
|
|
||||||
private PartType type;
|
private PartType type;
|
||||||
|
|
||||||
|
private class Property {
|
||||||
|
public final Supplier<String> getter;
|
||||||
|
public final Consumer<String> setter;
|
||||||
|
public final Set<String> possibleValues;
|
||||||
|
|
||||||
|
Property(Supplier<String> getter, Consumer<String> setter, Set<String> possibleValues) {
|
||||||
|
this.getter = getter;
|
||||||
|
this.setter = setter;
|
||||||
|
this.possibleValues = possibleValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Property> properties = new HashMap<>();
|
||||||
|
|
||||||
|
protected void addProperty(String name, Supplier<String> getter, Consumer<String> setter, Set<String> possibleValues) {
|
||||||
|
properties.put(name, new Property(getter, setter, possibleValues));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getPropertyNames() {
|
||||||
|
return Collections.unmodifiableSet(properties.keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getProperty(String propertyName) {
|
||||||
|
Objects.requireNonNull(propertyName);
|
||||||
|
|
||||||
|
if (properties.containsKey(propertyName)) {
|
||||||
|
return Optional.of(properties.get(propertyName).getter.get());
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProperty(String propertyName, String propertyValue) {
|
||||||
|
Objects.requireNonNull(propertyName);
|
||||||
|
Objects.requireNonNull(propertyValue);
|
||||||
|
|
||||||
|
if ((properties.containsKey(propertyName)) && (properties.get(propertyName).setter != null)) {
|
||||||
|
properties.get(propertyName).setter.accept(propertyValue);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("bad property name or value: " + propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getAvailablePropertyValues(String propertyName) {
|
||||||
|
if (properties.containsKey(propertyName)) {
|
||||||
|
return Collections.unmodifiableSet(properties.get(propertyName).possibleValues);
|
||||||
|
}
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
public Category getCategory(){
|
public Category getCategory(){
|
||||||
return this.type.getCategory();
|
return this.type.getCategory();
|
||||||
}
|
}
|
||||||
public PartType getType(){
|
public PartType getType(){
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public Set<String> getPropertyNames() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Set<String> getAvailablePropertyValues(String propertyName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Optional<String> getProperty(String propertyName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setProperty(String propertyName, String propertyValue) {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,37 @@
|
|||||||
package src.fr.impl;
|
package src.fr.impl;
|
||||||
|
|
||||||
import src.fr.api.Category;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PartTypeImpl implements src.fr.api.PartType {
|
import src.fr.api.Category;
|
||||||
|
import src.fr.api.PartType;
|
||||||
|
|
||||||
|
public class PartTypeImpl implements PartType {
|
||||||
private String name;
|
private String name;
|
||||||
private Category category;
|
private Category category;
|
||||||
|
|
||||||
//V2 implement
|
//V2 implement
|
||||||
private Class<? extends PartImpl> classRef;
|
private Class<? extends PartImpl> classRef;
|
||||||
|
|
||||||
public PartTypeImpl(String name, Category category ) {
|
public PartTypeImpl(String name,Class<? extends PartImpl> classref, Category category ) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.classRef= classref;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PartImpl newInstance(){
|
||||||
|
Constructor<? extends PartImpl> constructor;
|
||||||
|
try{
|
||||||
|
constructor = classRef.getConstructor();
|
||||||
|
return constructor.newInstance();
|
||||||
|
} catch(Exception e){
|
||||||
|
Logger.getGlobal().log(Level.SEVERE, "constructor call failed",e);
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName(){
|
public String getName(){
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user