20172303 2017-2018-2 "Programming and Data Structures" Pair Programming Project - The Second Week of Four Algorithms

20172303 2017-2018-2 "Programming and Data Structures" Pair Programming Project - The Second Week of Four Algorithms

paired object

  • Name: Fan Wenqi
  • Student ID: 20172322
  • Blog address for the first week
  • Take on the role:
    • Pilot: Fan Wenqi
    • Driver: Zhang Haoran
    • The basic requirements of the second week have been fulfilled in the first week, so the main task of this week is to complete the expansion requirement 6: (file processing), because in the Monday class, Mr. Wang has mentioned the related IO stream processing methods, although there are many detailed. Therefore, the method to be used this time was conceived by Fan Wenqi, and the actual operation was completed by me.

demand analysis

Requirements realized in the first week:

  • Questions can be automatically generated, and the difficulty and number of questions can be input by the user
  • The questions support integers, true fractions and four arithmetic operations of addition, subtraction, multiplication and division
  • It can judge whether the user's answer is correct and output the correct answer, and finally calculate the correct rate of the user

The main expansion requirements realized this week:

  • File processing: Put the randomly generated questions into the Exercises.txt file under the requirements of last week, let the user write the answer in it and save the file, run another class to make the question judged, and make the judgement result generated in ExercisesResult .txt file.

Design ideas

  • Main idea: Design the Questions class and the Results class to separate the previous ArithmeticTest class, and write the generated questions into the Exercises.txt file in the Questions class, and let the user save it after answering in the Exercises.txt file. The Results class reads the questions and answers in Exercises.txt and judges whether they are right or wrong, and puts the judgement results into ExercisesResult.txt.

  • UML graphics

Relevant process and explanation

  • This week, the main implementation of file processing, the brackets have been implemented last week, and there is still no idea to de-duplicate the topic.
    • In order to achieve writing randomly generated questions into Exercises.txt, use PrintStream

    and use

    Open files directly for users to facilitate user input.
    • Utilize in the Results class

        读取Exercises.txt中的题目与答案,并且利用    ![](https://images2018.cnblogs.com/blog/1333109/201805/1333109-20180508221240783-2032405467.png)

Write in ExercisesResult.txt.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325970206&siteId=291194637