ToDegree: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
K (Spobel verschob die Seite ToDegrees nach ToDegree)
Zeile 1: Zeile 1:
 
=== Beschreibung ===
 
=== Beschreibung ===
  
Die Funktion ''toDegrees'' wandelt Radiant-Werte in Grad um. Die Funktion erwartet einen Radiant und gibt den entsprechenden Grad zurück.
+
Die Funktion ''toDegree'' wandelt Radiant-Werte in Grad um. Die Funktion erwartet einen Radiant und gibt den entsprechenden Grad zurück.
  
 
=== Syntax ===
 
=== Syntax ===
  toDegrees(float radiant)
+
  toDegree([[Gleitkommazahl]] radiant)
  
 
=== Parameter ===
 
=== Parameter ===
Zeile 14: Zeile 14:
 
=== Beispiele ===
 
=== Beispiele ===
 
==== Standardfälle ====
 
==== Standardfälle ====
  toDegrees(3.14159)  --> returns 180
+
  toDegree(3.14159)  --> returns 180
  toDegrees(6.28319)  --> returns 360
+
  toDegree(6.28319)  --> returns 360
  
 
==== Benutzung mit Variablen ====
 
==== Benutzung mit Variablen ====
  toDegrees([pos=1])
+
  toDegree([pos=1])
  toDegrees([var=a])
+
  toDegree([var=a])
  
 
====JUnit Tests====
 
====JUnit Tests====
Zeile 48: Zeile 48:
 
@Test
 
@Test
 
public void testToDegrees1() {
 
public void testToDegrees1() {
assertEquals(540, Evaluator.getNumberResult("toDegrees(" + 3 * PI + ")", exerVar, fillIn), 0);
+
assertEquals(540, Evaluator.getNumberResult("toDegree(" + 3 * PI + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees2() {
 
public void testToDegrees2() {
assertEquals(360, Evaluator.getNumberResult("toDegrees(" + 2 * PI + ")", exerVar, fillIn), 0);
+
assertEquals(360, Evaluator.getNumberResult("toDegree(" + 2 * PI + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees3() {
 
public void testToDegrees3() {
assertEquals(180, Evaluator.getNumberResult("toDegrees(" + PI + ")", exerVar, fillIn), 0);
+
assertEquals(180, Evaluator.getNumberResult("toDegree(" + PI + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees4() {
 
public void testToDegrees4() {
assertEquals(-180, Evaluator.getNumberResult("toDegrees(" + -PI + ")", exerVar, fillIn), 0);
+
assertEquals(-180, Evaluator.getNumberResult("toDegree(" + -PI + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees5() {
 
public void testToDegrees5() {
assertEquals(90, Evaluator.getNumberResult("toDegrees(" + PI / 2 + ")", exerVar, fillIn), 0);
+
assertEquals(90, Evaluator.getNumberResult("toDegree(" + PI / 2 + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees6() {
 
public void testToDegrees6() {
assertEquals(45, Evaluator.getNumberResult("toDegrees(" + PI / 4 + ")", exerVar, fillIn), 0);
+
assertEquals(45, Evaluator.getNumberResult("toDegree(" + PI / 4 + ")", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegrees7() {
 
public void testToDegrees7() {
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees(1)", exerVar, fillIn), 0);
+
assertEquals(180 / PI, Evaluator.getNumberResult("toDegree(1)", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithInput1() {
 
public void testToDegreesWithInput1() {
assertEquals(90, Evaluator.getNumberResult("toDegrees('[pos=90]')", exerVar, fillIn), 0);
+
assertEquals(90, Evaluator.getNumberResult("toDegree('[pos=90]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithInput2() {
 
public void testToDegreesWithInput2() {
assertEquals(45, Evaluator.getNumberResult("toDegrees('[pos=45]')", exerVar, fillIn), 0);
+
assertEquals(45, Evaluator.getNumberResult("toDegree('[pos=45]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithInput3() {
 
public void testToDegreesWithInput3() {
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees('[pos=1]')", exerVar, fillIn), 0);
+
assertEquals(180 / PI, Evaluator.getNumberResult("toDegree('[pos=1]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithVariables1() {
 
public void testToDegreesWithVariables1() {
assertEquals(360, Evaluator.getNumberResult("toDegrees('[var=degd]')", exerVar, fillIn), 0);
+
assertEquals(360, Evaluator.getNumberResult("toDegree('[var=degd]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithVariables2() {
 
public void testToDegreesWithVariables2() {
assertEquals(180, Evaluator.getNumberResult("toDegrees('[var=degc]')", exerVar, fillIn), 0);
+
assertEquals(180, Evaluator.getNumberResult("toDegree('[var=degc]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithVariables3() {
 
public void testToDegreesWithVariables3() {
assertEquals(180 / PI, Evaluator.getNumberResult("toDegrees('[var=b]')", exerVar, fillIn), 0);
+
assertEquals(180 / PI, Evaluator.getNumberResult("toDegree('[var=b]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithVariables4() {
 
public void testToDegreesWithVariables4() {
assertEquals(180, Evaluator.getNumberResult("toDegrees('[var=PI]')", exerVar, fillIn), 0);
+
assertEquals(180, Evaluator.getNumberResult("toDegree('[var=PI]')", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithPointNumbers1() {
 
public void testToDegreesWithPointNumbers1() {
assertEquals(.2 * 180 / (PI), Evaluator.getNumberResult("toDegrees(0.2)", exerVar, fillIn), 0);
+
assertEquals(.2 * 180 / (PI), Evaluator.getNumberResult("toDegree(0.2)", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithPointNumbers2() {
 
public void testToDegreesWithPointNumbers2() {
assertEquals(.1 * 180 / (-PI), Evaluator.getNumberResult("toDegrees(-0.1)", exerVar, fillIn), 0);
+
assertEquals(.1 * 180 / (-PI), Evaluator.getNumberResult("toDegree(-0.1)", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithExpressions1() {
 
public void testToDegreesWithExpressions1() {
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegrees(0))", exerVar, fillIn), 0);
+
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegree(0))", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test
 
@Test
 
public void testToDegreesWithExpressions2() {
 
public void testToDegreesWithExpressions2() {
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegrees(toDegrees(0)))", exerVar, fillIn), 0);
+
assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegree(toDegree(0)))", exerVar, fillIn), 0);
 
}
 
}
  
 
@Test(expected = FunctionInvalidArgumentTypeException.class)
 
@Test(expected = FunctionInvalidArgumentTypeException.class)
 
public void testToDegreesWithWrongInputCharacter() {
 
public void testToDegreesWithWrongInputCharacter() {
Evaluator.getNumberResult("toDegrees(a)", exerVar, fillIn);
+
Evaluator.getNumberResult("toDegree(a)", exerVar, fillIn);
 
}
 
}
  
 
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 
public void testToDegreesWithTwoArguments() {
 
public void testToDegreesWithTwoArguments() {
Evaluator.getNumberResult("toDegrees(4, 3)", exerVar, fillIn);
+
Evaluator.getNumberResult("toDegree(4, 3)", exerVar, fillIn);
 
}
 
}
  
 
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
 
public void testToDegreesWithThreeArguments() {
 
public void testToDegreesWithThreeArguments() {
Evaluator.getNumberResult("toDegrees(2, 3, 4)", exerVar, fillIn);
+
Evaluator.getNumberResult("toDegree(2, 3, 4)", exerVar, fillIn);
 
}
 
}
  
 
@Test(expected = UndefinedExerciseVariableException.class)
 
@Test(expected = UndefinedExerciseVariableException.class)
 
public void testToDegreesWithMissingExerciseVariable() {
 
public void testToDegreesWithMissingExerciseVariable() {
Evaluator.getNumberResult("toDegrees('[var=j]')", exerVar, fillIn);
+
Evaluator.getNumberResult("toDegree('[var=j]')", exerVar, fillIn);
 
}
 
}
  
 
@Test(expected = UndefinedFillInVariableException.class)
 
@Test(expected = UndefinedFillInVariableException.class)
 
public void testToDegreesWithMissingInput() {
 
public void testToDegreesWithMissingInput() {
Evaluator.getNumberResult("toDegrees('[pos=42]')", exerVar, fillIn);
+
Evaluator.getNumberResult("toDegree('[pos=42]')", exerVar, fillIn);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 5. Oktober 2017, 09:02 Uhr

Beschreibung

Die Funktion toDegree wandelt Radiant-Werte in Grad um. Die Funktion erwartet einen Radiant und gibt den entsprechenden Grad zurück.

Syntax

toDegree(Gleitkommazahl radiant)

Parameter

  • radiant - der umzuwandelnde Radiant-Wert

Return Value

  • Gibt den Radiant-Wert in Grad zurück

Beispiele

Standardfälle

toDegree(3.14159)   --> returns 180
toDegree(6.28319)   --> returns 360

Benutzung mit Variablen

toDegree([pos=1])
toDegree([var=a])

JUnit Tests

[Anzeigen]

@BeforeClass
public static void beforeTest() {
	OMOBJ piFourth = new OMOBJ();
	OMOBJ piHalf = new OMOBJ();
	OMOBJ pi = new OMOBJ();
	OMOBJ twoPi = new OMOBJ();
	OMOBJ one = new OMOBJ();
	piFourth.setOMF(OMCreator.createOMF(PI / 4));
	piHalf.setOMF(OMCreator.createOMF(PI / 2));
	pi.setOMF(OMCreator.createOMF(PI));
	twoPi.setOMF(OMCreator.createOMF(2 * PI));
	one.setOMI(OMCreator.createOMI(1));

	fillIn.put(45, piFourth);
	fillIn.put(90, piHalf);
	fillIn.put(1, one);

	exerVar.put("degc", pi);
	exerVar.put("degd", twoPi);
	exerVar.put("b", one);
}

@Test
public void testToDegrees1() {
	assertEquals(540, Evaluator.getNumberResult("toDegree(" + 3 * PI + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees2() {
	assertEquals(360, Evaluator.getNumberResult("toDegree(" + 2 * PI + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees3() {
	assertEquals(180, Evaluator.getNumberResult("toDegree(" + PI + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees4() {
	assertEquals(-180, Evaluator.getNumberResult("toDegree(" + -PI + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees5() {
	assertEquals(90, Evaluator.getNumberResult("toDegree(" + PI / 2 + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees6() {
	assertEquals(45, Evaluator.getNumberResult("toDegree(" + PI / 4 + ")", exerVar, fillIn), 0);
}

@Test
public void testToDegrees7() {
	assertEquals(180 / PI, Evaluator.getNumberResult("toDegree(1)", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithInput1() {
	assertEquals(90, Evaluator.getNumberResult("toDegree('[pos=90]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithInput2() {
	assertEquals(45, Evaluator.getNumberResult("toDegree('[pos=45]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithInput3() {
	assertEquals(180 / PI, Evaluator.getNumberResult("toDegree('[pos=1]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithVariables1() {
	assertEquals(360, Evaluator.getNumberResult("toDegree('[var=degd]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithVariables2() {
	assertEquals(180, Evaluator.getNumberResult("toDegree('[var=degc]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithVariables3() {
	assertEquals(180 / PI, Evaluator.getNumberResult("toDegree('[var=b]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithVariables4() {
	assertEquals(180, Evaluator.getNumberResult("toDegree('[var=PI]')", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithPointNumbers1() {
	assertEquals(.2 * 180 / (PI), Evaluator.getNumberResult("toDegree(0.2)", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithPointNumbers2() {
	assertEquals(.1 * 180 / (-PI), Evaluator.getNumberResult("toDegree(-0.1)", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithExpressions1() {
	assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegree(0))", exerVar, fillIn), 0);
}

@Test
public void testToDegreesWithExpressions2() {
	assertEquals(0, Evaluator.getNumberResult("toDegrees(toDegree(toDegree(0)))", exerVar, fillIn), 0);
}

@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testToDegreesWithWrongInputCharacter() {
	Evaluator.getNumberResult("toDegree(a)", exerVar, fillIn);
}

@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testToDegreesWithTwoArguments() {
	Evaluator.getNumberResult("toDegree(4, 3)", exerVar, fillIn);
}

@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testToDegreesWithThreeArguments() {
	Evaluator.getNumberResult("toDegree(2, 3, 4)", exerVar, fillIn);
}

@Test(expected = UndefinedExerciseVariableException.class)
public void testToDegreesWithMissingExerciseVariable() {
	Evaluator.getNumberResult("toDegree('[var=j]')", exerVar, fillIn);
}

@Test(expected = UndefinedFillInVariableException.class)
public void testToDegreesWithMissingInput() {
	Evaluator.getNumberResult("toDegree('[pos=42]')", exerVar, fillIn);
}

Hinweise