"Building of the law" - the second work

GIT address git address
GIT Username Luo-Star
Student ID after five 62309
blog address Personal blog Home
Job Link Job Link

First, configure the environment

 About environment configuration, it is to configure before I had vs2017, but when I installed when not equipped with c # component, you need to reinstall it. But the problem is re-installed, Visual Studio Installer to download and install the speed is really slow, so I changed a way, I downloaded the offline version of VS2015 (with c ++ modules)
  
 on the map is being installed picture, because it is the offline version, all components have to download the full up, they only perform the installation just fine, and very fast

 after this is to configure a basic environment, Development Settings choose General on the line do not choose C #, we can go established C # project, the theme, I personally prefer the dark, choose the dark.

 Here, basically completes the installation of the software, c ++ environment software installation package automatically configured.

Second, the code design ideas

 Primary four operations to automatically generate and solve problems Title
 first problem to be solved is randomly generated symbols and four arithmetic symbols randomly generated numbers problems, there symbols +, -, *, / four kinds, a random number is generated randomly 0-100 , then the need to use a random function

 diagram is a method of randomly generated symbols symbol class I defined, the definition of an array of characters stored in an array of four operation symbol, as the array index by generating random numbers randomly symbol to generate symbols, and the resulting converted to a string return, but itself in C # function generates a random number is generated by a pseudo-random number, if you call too quickly, it will produce the same number, so I added a Thread .Sleep (15); the sleep function, preventing all the same symbol generation

 method of the same, and a method of obtaining a random number of symbols obtained similarly as shown above

 since it has been done to generate the random number-sign operation, it is next these are natural numbers and symbols randomly generated expressions, TwoSymbolCal () this method is an operation of generating symbols containing two operations Promoter, in this method, examples of a Symbol A, the random generation function by the two calling Symbol obtain random numbers and symbols, and spliced into a string (why is assembled into a string? Because Compute Method only accept parameter string type), a final result of the calculation using the method of the DataTable Compute, then the final result of the calculation expression before the splicing string,

 which is a method of producing arithmetic expression containing three symbols, generally as the method for producing and two arithmetic expressions containing arithmetic symbols, not to say here

 the last is the main function, the main function let the user enter a number, this number represents the number of the subject, and then enters a while loop, because it is randomly generated formula 2-3 operation symbol, by the same method, a random number is generated and modulo 2, if the remainder is 0, the calculation formula generation operation comprises two symbols, if the remainder is 1, the generating comprising arithmetic operation symbol three equations. Then we judge the results returned contain a minus sign and decimal point, if there is regenerated, if not written to a text file.

Three, github clone project and the entire process of recording commit code

1.GitHub cloning project


  Here has been successful from A super-cloned into their own warehouses, but after I installed git, when you run git bash, no way were cloned using the tutorial that method,

 and then I had Baidu, when we need to clone the project to the local when authentication is required, and git authentication methods are two, one is to use SSH for authentication, and the other is https to verify, I chose to use SSH for authentication.

 First set up in git git bash the user name and email, registered mail is its own git when the mailbox, as shown above

 and then generate a key, and finally will get two files locally, as shown below

 created after, we also need to add in the above git ssh key we just generated into git personal home page settings, as shown below

 and then find SSH and GPG keys to add SSH keys, pay attention because two files, we just suffix .pub content copied to key in, Title I could easily get a description and then click Add SSH key is good, then we can test

 well, here, I can successfully be cloned using SSH.

 When cloning should look, should clone a warehouse under their own account, I will be blind shining tutorials go step by step before the command is clone, so it leads to mistakes, so when we look at the tutorial, but also fixed point brain, not to blindly copy from. Here, I cloning process has been largely completed.

2. Code submitted

 Code submitted no big problem, but there is still a small problem, cloned from a remote to a local warehouse after set up a folder for placing your own code in the clone folder, but can not be uploaded to the remote warehouse

 use git push when prompted me to upload everything up-to-date, I thought I uploaded successfully, but could not find the remote repository, continue Baidu a bit, because there is no "submit information" git commit -m

 in my after executing git commit -m "submit information" of this order, uploaded to a remote repository, is complete.

Fourth, the project process unit testing and regression testing

 1. unit test project

  This unit test I did spend a lot of time, because my method returns a random symbols and randomly generated number, and unit testing, Assert assertion functions provided by the function is to achieve the desired value and the actual value comparison, only two determined, it may be I am more vegetables, I use one of the most stupid way. FIG following

  method randomly generated symbols on FIG operation test, because the return is a random array of characters, and I do not know what is generated, I used an if statement, if the generation is four so by any one test, or do not pass. Because my method, such random are returned, so the other test method is the same.

  Finally, this figure is a result of the operator unit generates random testing.

 2. the project regression testing

 After our code fixes, improvements or reconstruction, but also to re-run the unit tests again to see samples before meets. Regression testing their own code, not encountered particularly big problem, this is not uploaded screenshots.

 3. Effectiveness Analysis Test


  The figure is about my program performance CPU usage view.


  The above two graphs, the first one is being tested CPU usage when running a program, the second figure is the analysis report.

V. Summary

 The very beginning to do this one job, because the code segment trapped for a long time, I thought to write code that is most painful in itself that they are not very familiar with C #, grammar, what are forgotten almost, but when I tough finish when the code snippet, find the need to write their own test code, which made me very ignorant, because he wrote the code is not a good test, because the number of each cell are generated random or random symbols, Finally, a stupid way is realized, unit testing their own code. The job, let me have some previous knowledge forgotten it again picking up, such as unit tests Assert assertion function , array definition in C # , create a method of class , itself calls the class method , etc. , as well as how to create a unit test and test their own code, but also for regression testing in the modified code, and the code of conduct on the operational efficacy analysis view, in order to improve their own code to a module to improve efficiency .

Guess you like

Origin www.cnblogs.com/lwcblogs/p/11526215.html