Browse Source

Add ExpressionConvertible

master
Shadowfacts 3 years ago
parent
commit
c3541de871
Signed by: shadowfacts GPG Key ID: 94A5AB95422746E5
  1. 5
      .gitignore
  2. 9
      build.gradle
  3. 11
      local.properties
  4. 3
      settings.gradle
  5. 7
      src/main/java/no/birkett/kiwi/Expression.java
  6. 10
      src/main/java/no/birkett/kiwi/ExpressionConvertible.java
  7. 7
      src/main/java/no/birkett/kiwi/Term.java
  8. 7
      src/main/java/no/birkett/kiwi/Variable.java

5
.gitignore

@ -1,2 +1,7 @@
.idea/
/build
.gradle/
*.iml
*.ipr
*.iws
out/

9
build.gradle

@ -1,14 +1,13 @@
apply plugin: 'java'
apply plugin: 'idea'
apply from: "https://github.com/shadowfacts/maven/raw/master/maven.gradle"
sourceCompatibility = 1.7
targetCompatibility = 1.7
group = "no.birkett"
archivesBaseName = "kiwi"
version = '1.0'
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
distributionUrl = 'http://services.gradle.org/distributions/gradle-1.9-all.zip'
}
repositories {
mavenCentral()
}

11
local.properties

@ -1,11 +0,0 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sat Jan 31 12:43:25 CET 2015
sdk.dir=/Users/alex/sdk

3
settings.gradle

@ -1,4 +1 @@
rootProject.name = 'kiwi-java'
include 'lib'

7
src/main/java/no/birkett/kiwi/Expression.java

@ -6,7 +6,7 @@ import java.util.List;
/**
* Created by alex on 30/01/15.
*/
public class Expression {
public class Expression implements ExpressionConvertible {
private List<Term> terms;
@ -70,6 +70,11 @@ public class Expression {
}
@Override
public Expression toExpression() {
return this;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("isConstant: " + isConstant() + " constant: " + constant);

10
src/main/java/no/birkett/kiwi/ExpressionConvertible.java

@ -0,0 +1,10 @@
package no.birkett.kiwi;
/**
* @author shadowfacts
*/
public interface ExpressionConvertible {
Expression toExpression();
}

7
src/main/java/no/birkett/kiwi/Term.java

@ -3,7 +3,7 @@ package no.birkett.kiwi;
/**
* Created by alex on 30/01/15.
*/
public class Term {
public class Term implements ExpressionConvertible {
private Variable variable;
double coefficient;
@ -38,6 +38,11 @@ public class Term {
}
@Override
public Expression toExpression() {
return new Expression(this);
}
@Override
public String toString() {
return "variable: (" + variable + ") coefficient: " + coefficient;
}

7
src/main/java/no/birkett/kiwi/Variable.java

@ -3,7 +3,7 @@ package no.birkett.kiwi;
/**
* Created by alex on 30/01/15.
*/
public class Variable {
public class Variable implements ExpressionConvertible {
private String name;
@ -29,6 +29,11 @@ public class Variable {
}
@Override
public Expression toExpression() {
return new Expression(new Term(this));
}
@Override
public String toString() {
return "name: " + name + " value: " + value;
}

Loading…
Cancel
Save