我正在设置一个分数问题总和模板,如下所示:
Mark has 3 1/3 times as many apple as Jane. Jane has 42 apples. How many do they have altogether?
Template Possibility 1 - fraction first, then whole number
@name@1 has #name#1 #name#2/#mul#1 times as many @fruit@1 as @name@2. @name@2 has #name#3mul @fruit@1s. How many @fruit@1s do they have altogether?
Template Possibility 2 - whole number first , then fraction
Jane has 42 apples. Mark has 3 1/3 times as many apple as Jane.How many do they have altogether?
@name@1 has #name#1mul1 @fruit@1s. @name@2 has #name#2 #name#3/#mul#1 times as many @fruit@1 as @name@1. How many @fruit@1s do they have altogether?
Another possibility, there may be another pair : #name#2/#mul#1 #name#3mul1 #name#4/#mul#2 #name#5mul2
带# 的一个是数字变量,而带@ 的一个是文本变量。
对于文本变量和普通整数变量,我可以随机取值并将其放入模板中。
我对分数 (#name#2/#mul#1) 和整数 (#name#3mul) 有问题,这两者 以分母#mul#1必须能够除的方式相关整数(#name#3mul)没有任何余数或小数。
我有一种方法,在按顺序逐字检查时,如果找到第一个 #mul#1,它将调用一个方法并返回 2 个东西,即整数和 mul 值本身。
现在我有一个问题是要在问题模板中替换这 2 个值,因为整数可能先出现,然后是分数。
你们中的任何人都曾经经历过这种情况并且有更好的方法来生成可整除的分数和整数吗?
非常感谢任何建议或提示。谢谢!
PS:我用JAVA工作......