public code v1
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
package flintstones.domain.numeric.real;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.domain.numeric.NumericDomain;
|
||||
import flintstones.domain.numeric.real.messages.Messages;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class NumericRealDomain extends NumericDomain {
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
public static final String ID = "flintstones.domain.numeric.real"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void read(WNode node) {
|
||||
this.inRange = Boolean.parseBoolean(node.getAttribute(NumericDomain.Fields.inRange));
|
||||
if (!this.inRange) {
|
||||
this.min = 0.0d;
|
||||
this.max = 0.0d;
|
||||
} else {
|
||||
this.min = Double.parseDouble(node.getAttribute(NumericDomain.Fields.min));
|
||||
this.max = Double.parseDouble(node.getAttribute(NumericDomain.Fields.max));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package flintstones.domain.numeric.real.instance;
|
||||
|
||||
import flintstones.domain.numeric.real.NumericRealDomain;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.DomainInstance;
|
||||
|
||||
public class RealBetween0100Instance extends DomainInstance {
|
||||
|
||||
@Override
|
||||
public Domain getInstance() {
|
||||
|
||||
NumericRealDomain domain = (NumericRealDomain) getDomain();
|
||||
domain.setInRange(true);
|
||||
|
||||
double max = 100;
|
||||
double min = 0;
|
||||
|
||||
String name = getLabel();;
|
||||
|
||||
domain.setMax(max);
|
||||
domain.setMin(min);
|
||||
domain.setName(name);
|
||||
return domain;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package flintstones.domain.numeric.real.instance;
|
||||
|
||||
import flintstones.domain.numeric.real.NumericRealDomain;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.DomainInstance;
|
||||
|
||||
public class RealBetween010Instance extends DomainInstance {
|
||||
|
||||
@Override
|
||||
public Domain getInstance() {
|
||||
|
||||
NumericRealDomain domain = (NumericRealDomain) getDomain();
|
||||
domain.setInRange(true);
|
||||
|
||||
double max = 10;
|
||||
double min = 0;
|
||||
|
||||
String name = getLabel();;
|
||||
|
||||
domain.setMax(max);
|
||||
domain.setMin(min);
|
||||
domain.setName(name);
|
||||
return domain;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package flintstones.domain.numeric.real.instance;
|
||||
|
||||
import flintstones.domain.numeric.real.NumericRealDomain;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.DomainInstance;
|
||||
|
||||
public class RealNoRangeInstance extends DomainInstance {
|
||||
|
||||
@Override
|
||||
public Domain getInstance() {
|
||||
|
||||
NumericRealDomain domain = (NumericRealDomain) getDomain();
|
||||
|
||||
domain.setInRange(false);
|
||||
String name = getLabel();
|
||||
|
||||
domain.setName(name);
|
||||
return domain;
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package flintstones.domain.numeric.real.instance;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import flintstones.domain.numeric.real.NumericRealDomain;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.domain.DomainInstance;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
|
||||
public class RealRandomRangedInstance extends DomainInstance {
|
||||
|
||||
@Override
|
||||
public Domain getInstance() {
|
||||
|
||||
NumericRealDomain domain = (NumericRealDomain) getDomain();
|
||||
domain.setInRange(true);
|
||||
|
||||
Random rand = new Random();
|
||||
double n = (rand.nextDouble()*rand.nextInt()%10000);
|
||||
double m = (rand.nextDouble()*rand.nextInt()%10000);
|
||||
|
||||
if(m > n) {
|
||||
double x = n;
|
||||
n = m;
|
||||
m = x;
|
||||
}
|
||||
String name = getLabel() + " ["+DoubleHelper.Draw(m)+","+DoubleHelper.Draw(n)+"]_";
|
||||
|
||||
domain.setMax(n);
|
||||
domain.setMin(m);
|
||||
domain.setName(name);
|
||||
return domain;
|
||||
}
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package flintstones.domain.numeric.real.messages;
|
||||
|
||||
//This file has been auto-generated
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
public String category;
|
||||
public String name_intervalar;
|
||||
public String name;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
category=Numeric real
|
||||
name_intervalar=Numeric real intervalar
|
||||
name=Numeric real
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
category=Numérico real
|
||||
name_intervalar=Numérico real intervalar
|
||||
name=Numérico real
|
||||
Reference in New Issue
Block a user