ToDegree: Unterschied zwischen den Versionen

Aus JACK Wiki
Wechseln zu: Navigation, Suche
 
(2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
==Zugehörige Evaluatoren==
 +
*'''MathEvaluator'''
 
=== Beschreibung ===
 
=== Beschreibung ===
  
Zeile 15: Zeile 17:
 
==== Standardfälle ====
 
==== Standardfälle ====
 
  toDegree(3.14159)  --> returns 180
 
  toDegree(3.14159)  --> returns 180
 +
 
  toDegree(6.28319)  --> returns 360
 
  toDegree(6.28319)  --> returns 360
  
 
==== Benutzung mit Variablen ====
 
==== Benutzung mit Variablen ====
 
  toDegree([pos=1])
 
  toDegree([pos=1])
 +
 
  toDegree([var=a])
 
  toDegree([var=a])
 
====JUnit Tests====
 
<span class="mw-customtoggle-myDivision">[Anzeigen]</span>
 
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision">
 
@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);
 
}
 
</syntaxhighlight>
 
  
 
=== Hinweise ===
 
=== Hinweise ===
 
+
[[Kategorie:Math-Evaluatorfunktion]]
[[Kategorie:Evaluatorfunktion]]
 

Aktuelle Version vom 10. Dezember 2018, 12:15 Uhr

Zugehörige Evaluatoren

  • MathEvaluator

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])

Hinweise