285
社区成员




First of all, the general reading topic is divided into two parts. The first part is to identify the statistical keywords, and the second part is to identify the statistical code structure.
The first part is the first part. For the extraction of code keywords and statistics I think usinghash tables will be very easy to complete this part of the work.The specific idea is to retrieve the keywords in the hash table, and then add the counter if present. 1. Add a new key value pair if not present.
The second part is the structure identification specifically divided into three structures of the identification.
However, the identification idea of several structures is roughly the same.
Ststack the keywords and "{" and "}". Clear when the "}" heap goes into the stack, clear to the previous "{", and heap the cleared portion into the buffer.
The structure is analyzed into multi-level conditions, and the subsequent conditions will start to verify when the preconditions are completed.
Here the switch case structure is set to a two-level condition, with a precondition of switch stacking into the stack..
Turn on the switch when the precondition is reached, and count when the case enters the stack. And turn off the switch when the switch enters the buffer.
prefix condition : switch
decide condition : case
The structure takes if as a precondition and counts and switches off when the else enters the stack.
prefix condition : if
decide condition : else
This part will switch to the second structure, which I analyze as a three-level condition.
first condition : if else
second condition : else if
third condition :else
The first condition will use the judgment of the ifelse structure. Switch 1 will open as the counter of the ifelse increases.
The second switch tube will be open in the else if {} in the buffer.
The decision criteria will verify that the next entry keyword is else when the second switch is on.
The above is through the analysis after reading the problem.
for (String li : lists) {
if(li.length()<=1) continue;
if(!map.containsKey(li)) {//Detects if it is already in the table
map.put(li, 1);
}else {
Integer count = map.get(li);
map.put(li, ++count);
}
}
//type1 switch case
//Open the switch after switch enters the stack
if(i==0) {
sw1=true;
sw++;
}
if(sw1==true&&i==1) ca++;//Start the case counting after the switch is on
//Turn off the switch after "}" enters the stack and return to the zero counter
if(sw1==true&&i==5) {
System.out.println("number of switch"+sw+" case = "+ca);
ca=0;
sw1=false;
}
//type2 if else
//The if else only has an else decision condition, so it does not set up a switch
if(i==3) type2++;
//type3 if, else if, else
//Determine the precondition and complete the precondition and close the switch
if(sw2==true) {
if(i==3) type3++;
sw2=false;
}
if(li.equals(table[5])) {
//type3 if, else if, else
List<String> buffer = new ArrayList<String>();//Create the buffer judgment preconditions
sw2=true;
//Eliminate after the "}" goes into the stack
while(true) {
if(!st.empty()&&!st.peek().equals(table[4])) {
buffer.add(st.peek());
st.pop();
}else break;
}
if(!st.empty()) {
buffer.add(st.peek());
st.pop();
}
while(true) {
if(!st.empty()&&!st.peek().equals(table[4])) {
buffer.add(st.peek());
st.pop();
}else break;
}
//Judge the preconditions, the condition of the switch on
if(buffer.size()==4) {
for(int i=0;i<buffer.size();i++) {
if(!buffer.get(i).equals(type3buffer[i])) {
sw2=false;
break;
}
}
}else sw2=false;
}
}
psp | time |
---|---|
Planning | 10 |
Estimate | 60 |
Development | 50 |
Analysis | 30 |
Design Spec | 20 |
Design Review | 20 |
Coding Standard | 10 |
Design | 20 |
Coding | 20 |
Code Review | 40 |
Test | 10 |
Reporting | 50 |
Test Report | 30 |
Size Measurement | 10 |
Postmortem & Process Improvement Plan | 10 |
390 |
The Link Your Class | |
---|---|
The Link of Requirement of This Assignment | https://github.com/if-ish/EE308FZ-Lab1-2-Individual-programing-work |
The Aim of This Assignment | Keyword statistics and structure identification |
MU STU ID and FZU STU ID | <20124635_832002210> |