-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e66f5fb
commit f4aa746
Showing
23 changed files
with
776 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>edu.carole</groupId> | ||
<artifactId>PythonJava</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
</project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package env; | ||
|
||
import var_type.*; | ||
import var_type.var_roots.ClassObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
|
||
public class StaticVars { | ||
public static ClassObject OBJECT = new ClassObject(); | ||
public static ClassInt INT = new ClassInt(); | ||
public static ClassNullType NULL_TYPE = new ClassNullType(); | ||
public static ClassFloat FLOAT = new ClassFloat(); | ||
public static ClassBoolean BOOLEAN = new ClassBoolean(); | ||
public static InstancePermission DEFAULT_PERMISSION = new InstancePermission(OBJECT); | ||
public static InstanceBoolean BOOL_FALSE = new InstanceBoolean(DEFAULT_PERMISSION, false); | ||
public static InstanceBoolean BOOL_TRUE = new InstanceBoolean(DEFAULT_PERMISSION, true); | ||
public static InstanceNullType NULL = new InstanceNullType(DEFAULT_PERMISSION); | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import env.StaticVars; | ||
import var_type.InstanceFloat; | ||
import var_type.InstanceInt; | ||
|
||
public class test { | ||
|
||
public static void main(String[] args) { | ||
InstanceFloat num1 = new InstanceFloat(StaticVars.DEFAULT_PERMISSION, 2); | ||
System.out.println(num1.and(StaticVars.BOOL_TRUE).or(StaticVars.NULL)); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_interface.IInstance; | ||
import var_type.var_roots.ClassObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
|
||
public class ClassBoolean extends ClassObject { | ||
|
||
@Override | ||
public ClassObject[] parent() { | ||
return new ClassObject[]{StaticVars.OBJECT}; | ||
} | ||
|
||
@Override | ||
public String getKeyWord() { | ||
return "bool"; | ||
} | ||
|
||
@Override | ||
public IInstance getInstance(InstancePermission permission) { | ||
return super.getInstance(permission); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_interface.IInstance; | ||
import var_type.var_roots.ClassObject; | ||
import var_type.var_roots.InstanceObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
|
||
public class ClassFloat extends ClassObject { | ||
|
||
@Override | ||
public String getKeyWord() { | ||
return "float"; | ||
} | ||
|
||
@Override | ||
public ClassObject[] parent() { | ||
return new ClassObject[]{StaticVars.OBJECT}; | ||
} | ||
|
||
public IInstance getInstance(InstancePermission permission){ | ||
return new InstanceFloat(permission); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_interface.IInstance; | ||
import var_type.var_roots.ClassObject; | ||
import var_type.var_roots.InstanceObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
|
||
public class ClassInt extends ClassObject { | ||
|
||
public ClassInt() { | ||
super(); | ||
this.type = this; | ||
} | ||
|
||
public String getKeyWord() { | ||
return "int"; | ||
} | ||
|
||
@Override | ||
public ClassObject[] parent() { | ||
return new ClassObject[]{StaticVars.OBJECT}; | ||
} | ||
|
||
public IInstance getInstance(InstancePermission permission) { | ||
return new InstanceInt(permission); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_roots.ClassObject; | ||
|
||
public class ClassNullType extends ClassObject { | ||
@Override | ||
public String getKeyWord() { | ||
return "null"; | ||
} | ||
|
||
@Override | ||
public ClassObject[] getAllParents() { | ||
return new ClassObject[]{StaticVars.OBJECT}; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_interface.ILogicable; | ||
import var_type.var_roots.InstanceObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
|
||
public class InstanceBoolean extends InstanceObject implements ILogicable { | ||
|
||
boolean data; | ||
public InstanceBoolean(InstancePermission permission) { | ||
super(StaticVars.BOOLEAN, permission); | ||
} | ||
|
||
public InstanceBoolean(InstancePermission permission, boolean data) { | ||
this(permission); | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public boolean isPositive() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return data ? "True" : "False"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(!(obj instanceof ILogicable)) return false; | ||
return ((ILogicable) obj).isPositive() == isPositive(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package var_type; | ||
|
||
import env.StaticVars; | ||
import var_type.var_interface.IInstance; | ||
import var_type.var_interface.IInstanceNumber; | ||
import var_type.var_interface.ILogicable; | ||
import var_type.var_roots.ClassObject; | ||
import var_type.var_roots.InstanceObject; | ||
import var_type.var_roots.permission_control.InstancePermission; | ||
import var_type.var_roots.permission_control.PermissionTypes; | ||
|
||
public class InstanceFloat extends InstanceObject implements IInstanceNumber { | ||
double data = 0; | ||
|
||
public InstanceFloat(InstancePermission permission){ | ||
super(StaticVars.FLOAT, permission); | ||
} | ||
|
||
public InstanceFloat(InstancePermission permission, double data){ | ||
super(StaticVars.FLOAT, permission); | ||
this.data = data; | ||
} | ||
|
||
InstanceFloat(ClassObject myClass, InstancePermission permission) { | ||
super(myClass, permission); | ||
} | ||
|
||
InstanceFloat(ClassObject myClass) { | ||
super(myClass, InstancePermission.getDefault(myClass)); | ||
} | ||
|
||
InstanceFloat(ClassObject myClass, double data) { | ||
this(myClass); | ||
this.data = data; | ||
} | ||
|
||
public InstanceFloat(ClassObject myClass, double data, InstancePermission permission) { | ||
this(myClass, permission); | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public IInstanceNumber addWith(IInstanceNumber number) { | ||
if(number.is(this)) | ||
return new InstanceFloat(this.myClass, this.data + number.getNumber(), this.myPermission); | ||
return number.addWith(this); | ||
} | ||
|
||
@Override | ||
public IInstanceNumber minusWith(IInstanceNumber number) { | ||
if(number.is(this)) | ||
return new InstanceFloat(this.myClass, this.data - number.getNumber(), this.myPermission); | ||
return number.minusWith(this); | ||
} | ||
|
||
@Override | ||
public IInstanceNumber multiplyWith(IInstanceNumber number) { | ||
if(number.is(this)) | ||
return new InstanceFloat(this.myClass, this.data * number.getNumber(), this.myPermission); | ||
return number.multiplyWith(this); | ||
} | ||
|
||
@Override | ||
public IInstanceNumber divideWith(IInstanceNumber number) { | ||
if(number.is(this)) | ||
return new InstanceFloat(this.myClass, this.data / number.getNumber(), this.myPermission); | ||
return number.divideWith(this); | ||
} | ||
|
||
@Override | ||
public double getNumber() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public IInstance convertTo(ClassObject classType) { | ||
if(classType.equals(StaticVars.OBJECT) || classType.equals(StaticVars.FLOAT)) return this; | ||
if(classType.equals(StaticVars.INT)) { | ||
InstanceInt intObj = (InstanceInt) StaticVars.INT.getInstance(myPermission); | ||
intObj.data = (int) data; | ||
return intObj; | ||
} | ||
if(classType.equals(StaticVars.BOOLEAN)) { | ||
return isPositive() ? StaticVars.BOOL_TRUE : StaticVars.BOOL_FALSE; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isPositive() { | ||
return data > 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return data + ""; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(!(obj instanceof InstanceFloat)) return false; | ||
return ((InstanceFloat) obj).data == data; | ||
} | ||
} |
Oops, something went wrong.