Ejemplo n.º 1
0
        public void load()
        {
            // Type mathquiz load will assign to deserialize to load the quiz from the quiz that was saved.
            SaveQuiz load = JsonConvert.DeserializeObject <SaveQuiz>(File.ReadAllText("Mathfile"));

            //assigning all variables that were used to load so the program will load everything in the quiz.

            randMath       = load.randMath;
            check          = load.check;
            AmountCorrect  = load.AmountCorrect;
            totalQuestions = load.totalQuestions;
            numA           = load.numA;
            numB           = load.numB;
            totalA         = load.totalA;
            num1.Text      = Convert.ToString(numA);
            num2.Text      = Convert.ToString(numB);
            total.Text     = Convert.ToString(totalA);

            StartAfterLoad();
        }
Ejemplo n.º 2
0
        public void save()
        {
            /* gives math quiz a new instance of math quiz then assigns
             * the new instance of this*/
            SaveQuiz mathquiz = new SaveQuiz();

            //Assigning variables to save so the program will save what is being used.
            mathquiz.numA           = numA;
            mathquiz.numB           = numB;
            mathquiz.totalA         = totalA;
            mathquiz.randMath       = randMath;
            mathquiz.check          = check;
            mathquiz.AmountCorrect  = AmountCorrect;
            mathquiz.totalQuestions = totalQuestions;

            JsonSerializer serializer = new JsonSerializer();
            TextWriter     writer     = new StreamWriter("MathFile");

            serializer.Serialize(writer, mathquiz);
            writer.Close();
        }