-
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
Showing
13 changed files
with
215 additions
and
12 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
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
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
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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/fixie/generator/acceleration/AngularAccelerationClass.kt
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,22 @@ | ||
package fixie.generator.acceleration | ||
|
||
import fixie.generator.number.FloatType | ||
import fixie.generator.quantity.FloatQuantityClass | ||
import fixie.generator.quantity.QuantityUnit | ||
import fixie.generator.spin.SpinClass | ||
|
||
class AngularAccelerationClass( | ||
className: String, | ||
floatType: FloatType, | ||
val spinClassName: String?, | ||
createNumberExtensions: Boolean | ||
) : FloatQuantityClass(className, floatType, createNumberExtensions) { | ||
|
||
var spin: SpinClass? = null | ||
|
||
override fun getSupportedUnits() = listOf( | ||
QuantityUnit( | ||
"RADPS2", "", "rad/s^2", "radps2", 0.0001, 1e6, 1.0 | ||
) | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/fixie/generator/acceleration/AngularAccelerationClassGenerator.kt
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,40 @@ | ||
package fixie.generator.acceleration | ||
|
||
import fixie.generator.quantity.FloatQuantityClassGenerator | ||
import java.io.PrintWriter | ||
|
||
class AngularAccelerationClassGenerator( | ||
writer: PrintWriter, | ||
quantity: AngularAccelerationClass, | ||
packageName: String | ||
) : FloatQuantityClassGenerator<AngularAccelerationClass>(writer, quantity, packageName) { | ||
|
||
override fun getImports() = super.getImports() + arrayOf("kotlin.time.Duration", "kotlin.time.DurationUnit") | ||
|
||
override fun generateToDoubleComment() { | ||
writer.println("\t/** Gets the angular acceleration value, in rad/s^2 */") | ||
} | ||
|
||
override fun generateToString() { | ||
writer.println() | ||
writer.println("\toverride fun toString() = String.format(\"%.2f%s\", value, \"rad/s^2\")") | ||
} | ||
|
||
override fun generateArithmetic() { | ||
super.generateArithmetic() | ||
|
||
if (quantity.spin != null) { | ||
writer.println() | ||
writer.println("\toperator fun times(right: Duration) = value * ${quantity.spinClassName}.RADIANS_PER_SECOND * right.toDouble(DurationUnit.SECONDS)") | ||
} | ||
} | ||
|
||
override fun generateExtensionFunctions() { | ||
super.generateExtensionFunctions() | ||
|
||
if (quantity.spin != null) { | ||
writer.println() | ||
writer.println("operator fun Duration.times(right: ${quantity.className}) = right * this") | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/fixie/generator/acceleration/AngularAccelerationTestsGenerator.kt
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,33 @@ | ||
package fixie.generator.acceleration | ||
|
||
import fixie.generator.quantity.FloatQuantityTestsGenerator | ||
import java.io.PrintWriter | ||
|
||
class AngularAccelerationTestsGenerator( | ||
writer: PrintWriter, | ||
quantity: AngularAccelerationClass, | ||
packageName: String | ||
) : FloatQuantityTestsGenerator<AngularAccelerationClass>(writer, quantity, packageName) { | ||
|
||
override fun getImports() = super.getImports() + arrayOf("kotlin.time.Duration.Companion.seconds") | ||
|
||
override fun generateToStringBody() { | ||
writer.println("\t\tassertEquals(\"2.34rad/s^2\", (${quantity.className}.RADPS2 * 2.34).toString())") | ||
} | ||
|
||
override fun generateArithmeticBody() { | ||
super.generateArithmeticBody() | ||
|
||
if (quantity.spin != null) { | ||
writer.println("\t\tassertEquals(0.8, ((${quantity.className}.RADPS2 * 0.2) * 4.seconds).toDouble(SpinUnit.RADIANS_PER_SECOND), 0.01)") | ||
} | ||
} | ||
|
||
override fun generateExtensionFunctionsBody() { | ||
super.generateExtensionFunctionsBody() | ||
|
||
if (quantity.spin != null) { | ||
writer.println("\t\tassertEquals(0.8, (4.seconds * (${quantity.className}.RADPS2 * 0.2)).toDouble(SpinUnit.RADIANS_PER_SECOND), 0.01)") | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.