所以我目前正在开发一个Android项目,而且我在某个时候陷入困境;这是代码:
public class Readiness {
private Double examAverageReadiness;
private Integer courseReadiness;
private Integer courseScore;
public Integer courseCount;
//Set the number of courses offered
private void setCourseCount(Integer c) {
courseCount = c;
}
//Get readiness for individual course examinations
//'a' and 'b' are the course test scores
public Integer getCourseReadiness(Integer a, Integer b) {
Integer c = (a/15) * 100;
Integer d = (b/15) * 100;
Integer e = (c+d)/2;
//Double f = Double.parseDouble(e.toString());
courseReadiness = e;
return e;
}
//Get a predicted score in a course examination
public Integer getPredictableCourseScore(Integer a, Integer b) {
Integer r = (courseReadiness/100) * 70;
Integer i = r.intValue();
Integer d = i + a + b;
courseScore = d;
return d;
}
//This is the total readiness for a semester examination
public Double examRValue(Double tmc121, Double eds121, Double gst121, Double
gst122, Double cst121)
{
Double v = ((tmc121+eds121+gst121+gst122+cst121)/(courseCount*100)) * 100;
examAverageReadiness = v;
return v;
}
}
然后我在这里使用它:
private View.OnClickListener onClicke=new View.OnClickListener() {
public void onClick(View v){
EditText edtTxt = (EditText)findViewById(R.id.edtTxt);
edtTxt.setText("hello there!");
Readiness r = new Readiness();
r.courseCount = 5;
//TMC 121
EditText one = (EditText)findViewById(R.id.v1);
EditText two = (EditText)findViewById(R.id.v2);
Integer one1 = Integer.parseInt(one.getText().toString());
Integer two2 = Integer.parseInt(two.getText().toString());
Integer p = r.getCourseReadiness(one1, two2);
Log.d("pdsk", p.toString());
Integer f = r.getPredictableCourseScore(one1, two2);
TextView tmc = (TextView)findViewById(R.id.tmc121);
tmc.setText("Readiness: " + p.toString() + "% ExamScore: " + f);
//EDS 121
EditText three = (EditText)findViewById(R.id.v3);
EditText four = (EditText)findViewById(R.id.v4);
Integer three3 = Integer.parseInt(three.getText().toString());
Integer four4 = Integer.parseInt(four.getText().toString());
Integer e = r.getCourseReadiness(three3, four4);
Integer s = r.getPredictableCourseScore(three3, four4);
TextView eds = (TextView)findViewById(R.id.eds121);
eds.setText("Readiness: " + e.toString() + "% ExamScore: " + s);
}
}
在我调试它并发现Readiness.java类的方法之前,这对我没用,
“getCourseReadiness(整数a,整数b)”
始终返回0(零)值。这有点令人讨厌(虽然对我来说......)因为如果我在EditText字段中放置一个非零值,我期望一个非零值。所以,我希望我能从这个平台得到答案...(谢谢)。