Abgabeversion des zweiten Generators
This commit is contained in:
parent
1e6c09a5bb
commit
9069273211
Binary file not shown.
@ -2,14 +2,13 @@ package generators.maths;
|
||||
|
||||
import generators.framework.Generator;
|
||||
import generators.framework.GeneratorType;
|
||||
import interactionsupport.models.FillInBlanksQuestionModel;
|
||||
import interactionsupport.models.QuestionGroupModel;
|
||||
import interactionsupport.models.MultipleSelectionQuestionModel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import algoanim.primitives.IntMatrix;
|
||||
import algoanim.primitives.Rect;
|
||||
import algoanim.primitives.SourceCode;
|
||||
import algoanim.primitives.StringMatrix;
|
||||
import algoanim.primitives.generators.Language;
|
||||
@ -19,30 +18,19 @@ import algoanim.properties.RectProperties;
|
||||
import algoanim.properties.SourceCodeProperties;
|
||||
import algoanim.properties.TextProperties;
|
||||
import algoanim.util.Coordinates;
|
||||
import algoanim.util.DisplayOptions;
|
||||
import algoanim.util.Offset;
|
||||
import algoanim.util.Timing;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.commons.collections.functors.FalsePredicate;
|
||||
|
||||
import de.ahrgr.animal.kohnert.asugen.Font;
|
||||
import de.ahrgr.animal.kohnert.asugen.Rectangle;
|
||||
import de.ahrgr.animal.kohnert.asugen.Text;
|
||||
import generators.framework.properties.AnimationPropertiesContainer;
|
||||
import algoanim.animalscript.AnimalScript;
|
||||
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - Benutzerinteraktionen einfügen
|
||||
*
|
||||
* optional:
|
||||
* - Texte nicht als SourceCode-Objekte, sonder als Textobjekte erstellen. Somit können die Properties geändert werden.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class MatrixGenerator implements Generator {
|
||||
|
||||
@ -86,6 +74,12 @@ public class MatrixGenerator implements Generator {
|
||||
private IntMatrix intMatrixB = null;
|
||||
private IntMatrix intMatrixResult = null;
|
||||
|
||||
/**
|
||||
* The lines using rectanlges
|
||||
*/
|
||||
private Rect line1 = null;
|
||||
private Rect line2 = null;
|
||||
|
||||
/**
|
||||
* unhighlightingTime
|
||||
*/
|
||||
@ -220,6 +214,15 @@ public class MatrixGenerator implements Generator {
|
||||
this.summe = lang.newStringMatrix(new Offset(15, 0, intMatrixB, AnimalScript.DIRECTION_E), data, "stumme", null);
|
||||
this.summe.changeColor(AnimationPropertiesKeys.FILL_PROPERTY, Color.WHITE, null, null);
|
||||
|
||||
//generate lines using rectangles
|
||||
line1 = lang.newRect( new Offset(-4, 0, intMatrixB, AnimalScript.DIRECTION_NW),
|
||||
new Offset(-4, 0, intMatrixResult, AnimalScript.DIRECTION_SW),
|
||||
"line1", null);
|
||||
|
||||
line2 = lang.newRect( new Offset(0, -2, intMatrixA, AnimalScript.DIRECTION_NW),
|
||||
new Offset(0, -2, intMatrixResult, AnimalScript.DIRECTION_NE),
|
||||
"line2", null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,7 +234,7 @@ public class MatrixGenerator implements Generator {
|
||||
private void falk(){
|
||||
|
||||
//STEP
|
||||
lang.nextStep();
|
||||
lang.nextStep("Einleitung");
|
||||
info.hide();
|
||||
|
||||
//generate the source code
|
||||
@ -241,7 +244,7 @@ public class MatrixGenerator implements Generator {
|
||||
generateMatrices();
|
||||
|
||||
//STEP
|
||||
lang.nextStep();
|
||||
lang.nextStep("Der Algorithmus");
|
||||
sc.highlight(0);
|
||||
|
||||
//STEP
|
||||
@ -318,6 +321,8 @@ public class MatrixGenerator implements Generator {
|
||||
intMatrixA.hide();
|
||||
intMatrixB.hide();
|
||||
this.summe.hide();
|
||||
line1.hide();
|
||||
line2.hide();
|
||||
|
||||
|
||||
algoanim.primitives.Text ergebnis = lang.newText(new Offset(-60, 0, intMatrixResult, AnimalScript.DIRECTION_NW), "Ergebnis: ", "name", null);
|
||||
@ -336,17 +341,28 @@ public class MatrixGenerator implements Generator {
|
||||
*/
|
||||
private void generateStatement(){
|
||||
|
||||
lang.setInteractionType(Language.INTERACTION_TYPE_AVINTERACTION);
|
||||
|
||||
statement = lang.newSourceCode(new Coordinates(10, 75), "statement", null, TEXT_PROPS);
|
||||
statement.addCodeLine("Komplexität:", null, 0, null);
|
||||
|
||||
MultipleSelectionQuestionModel msq = new MultipleSelectionQuestionModel("multipleSelectionQuestion");
|
||||
msq.setPrompt("Welche Komplexität besitzt die behandelte Methode?");
|
||||
msq.addAnswer("O(n^2)", -1, "Nein, es handelt sich um O(n^3)!");
|
||||
msq.addAnswer("O(n^3)", 1, "Richtig!");
|
||||
msq.addAnswer("Omega(n^3)", -1, "Nein, es handelt sich um O(n^3)!");
|
||||
msq.setGroupID("Second question group");
|
||||
lang.addMSQuestion(msq);
|
||||
|
||||
//STEP
|
||||
lang.nextStep("Komplexität");
|
||||
|
||||
statement.addCodeLine("Abschließend wollen wir noch einen kurzen Blick auf die Komplexität des Verfahrens werfen.", null, 0, null);
|
||||
statement.addCodeLine("Die kritischen Elemente des Algorithmus sind die drei verschachtelten Schleifen.", null, 0, null);
|
||||
statement.addCodeLine("Die äußere Schleife läuft über die Anzahl n der Zeilen der Matrix A.", null, 0, null);
|
||||
statement.addCodeLine("Die mittlere Schleife läuft über die Anzahl m der Spalten der Matrix B.", null, 0, null);
|
||||
statement.addCodeLine("Die innere Schleife läuft über die Anzahl p der Spalten von A.", null, 0, null);
|
||||
statement.addCodeLine("Durch Anwendung der Produktregel erhalten wir somit eine kubische Komplexität von O(n^3).", null, 0, null);
|
||||
//TODO: implement the statement for the last view slides!
|
||||
|
||||
//Zeilenazahl(A) * Spaltenanzahl(B) * Spaltenanzah(A)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user