EE308 LAB2

The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZ?category=0
The Link of Requirement of This Assignmenthttps://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 ID19103662 & 831902222

 

PSP form

Personal Software Process StageEstimated Time/minutesCompleted Time/Minutes
Planning3030
Estimate1515
Development--

Analysis

6060

Design Spec

9090

Design Review

1010

Coding Standard

6060

Design

6060

Coding

120120

Code Review

3030

Test

1010
Reporting6060

Test Report

55

Size Measurement

1010

Postmortem&Process  Improvement

6060
total620620

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.

 

我勒个去