The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZ?category=0 |
---|---|
The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/600798588 |
The Aim of This Assignment | To achieve a program function, it can extract keywords of different levels from the C or C++ code files that are read in. |
MU STU ID and FZU STU ID | 19103662 & 831902222 |
PSP form
Personal Software Process Stage | Estimated Time/minutes | Completed Time/Minutes |
Planning | 30 | 30 |
Estimate | 15 | 15 |
Development | - | - |
Analysis | 60 | 60 |
Design Spec | 90 | 90 |
Design Review | 10 | 10 |
Coding Standard | 60 | 60 |
Design | 60 | 60 |
Coding | 120 | 120 |
Code Review | 30 | 30 |
Test | 10 | 10 |
Reporting | 60 | 60 |
Test Report | 5 | 5 |
Size Measurement | 10 | 10 |
Postmortem&Process Improvement | 60 | 60 |
total | 620 | 620 |
Problem-solving ideas
When I saw the topic,I knew this question requests us to extract some keywords from a file.And until now,I am good at extracting code from a file through C++.Hence,I decided to choose C++ language to solve this problem.
Design
This is a probelm that is to find the number of these keywords.So,first,we need to build a string that includes all keywords so that when we extract a word,we can test if it meets the requirement.And we need find all keywords in the file and calculate the number of them.After that we output the result and compare it with the right answer in the topic.
Implementation process
Code description
i)First,we need bulid many related variables,such as inFile,level and so on.Most importantly,we need have a string that includes all keywords.
ii)Second,we need to find the number of keywords.The process is pretty easy.We just need to find the keywords and calculate the amount.But extracting these words is too difficult.
iii)Third,you know,when I find the number of switch case,I just need to find the number of switch.Because when switch occurs,case must happen.As for case,we only find the number of them after the keyword switch exists.
iv)Then,we need to find the number of if else.It have a problem that we have to solve.That is when I find the keyword if,I don't determine whether it is the structure of if-else or if-else if-else.Therefore,we have to know the first keyword after the keyword if.The codes are as follows:
v)You know,we have solve the problem about the number of if-else.Hence the idea is same when we find the number of if-else if-else.
Unit test
When I run this program,it will calculate the number in order.Hence,we get the amout of keywords,swith case,case......
Summary
For this lab,I review a lot of knowledge that I forget.To be honest,this lab is very useful.I know how to extract keywords and calculate the number of them.Besides,I know how to draw the photo of the process.You know,in the other homework,we don't need to do this,but,this homework trains us.Most importantly,when I solve this problem,I discuss with my classmates and friends sometimes.I think it's essential for me.
我勒个去