First, the experimental process:
1. First create a document named after the study number:
2. A percentile result is converted to a grade:
3. Create a new package and another test:
4. Open UML, modeling software Umbrello to model:
Related programs:
5. My saves:
Second, the problems encountered and solutions:
The experiment in general is quite smooth, that is, I want to spend a lot of time while doing. But there are some small problems.
For example, the changes in the model diagram of UML modeling from cat and dog to animal including cat and dog are not very detailed in the experimental guidance,
So I've started not to do it. But later understand that animal also need to build their own new, so then thoroughly understand the use of UML in this experiment.
You can also draw a connection line yourself.
Three, PSP time statistics:
Step time-consuming percentage
Demand Analysis 40%
Design 20%
Code implementation 10%
Test 10%
Analysis Summary 20%
Iv. design and implement the plural class complex using TDD method
1. Product Code:
public class Complex {
Real part realpart, imaginary part Imaginpart
Private double Realpart;
Private double Imaginpart;
Complex-class complex () constructor that resets the imaginary part of the real to 0
Public Complex () {
This.realpart = 0;
This.imaginpart = 0;
}
Complex (double r,double i) creates a complex object while completing the real part of the complex, initializing the imaginary part
Public Complex (double r,double i) {
This.realpart = R;
This.imaginpart = i;
}
Getrealpart () get the real part
Public double Getrealpart () {
return realpart;
}
Getimaginarypart () Get imaginary part
Public double Getimaginarypart () {
return imaginpart;
}
Setrealpart (double D) setting the real part
public void Setrealpart (double d) {
This.realpart = D;
}
Setimaginarypart (double D) Set imaginary part
public void Setimaginarypart (double d) {
This.imaginpart = D;
}
Add (Complex c) Complex sum
public void Add (Complex C1,complex C2) {
Complex C = new Complex (C1.realpart+c2.realpart,c1.imaginpart+c2.imaginpart);
print (c);
}
Minus (Complex c) Complex subtraction
public void minus (Complex C1,complex C2) {
Complex C = new Complex (C1.realpart-c2.realpart,c1.imaginpart-c2.imaginpart);
print (c);
}
Complexmulti (Complex c) Multiply plural
public void Complexmulti (Complex C1,complex C2) {
Complex C = new Complex (c1.realpart*c2.realpart-c1.imaginpart*c2.imaginpart,c1.realpart*c2.imaginpart+ C1.imaginpart*c2.realpart);
print (c);
}
ToString () combines the real part of the current complex object with the imaginary part into a a+bi string form
public void print (Complex c) {
Double A = C.realpart;
Double b = c.imaginpart;
System.out.println (A + "+" +b+ "I");
}
}
2. Test the code:
Import Org.junit.Test;
Import Junit.framework.TestCase;
public class Complextest extends Complex {
@Test
public void Printtest () {
Complex C1 = new Complex (3.5,9);
Complex C2 = new Complex (9,23);
Complex C = new Complex ();
C.complexmulti (c1, C2);
C.add (c1, C2);
C.minus (c1, C2);
}
}
Five, experience
The experiment is not difficult, but there are a lot of things to see. And with the exception of Java programming, something else,
For example, UML modeling software. And the feeling of every experiment is that it can touch a lot of new things, and it has improved for me.
Java Second Experiment 20135204