-4
你好,我每一个人在Android的新,现在我想创建一个功能,得到一个人的年龄,并告诉他们在哪个组,他们是,例如如果年龄介于4至11岁之间,那么他们就在小组中......但我有一个问题,我不知道应该怎么回报? 感谢任何帮助 这里是我的代码:得到一个人在Android的年龄,并告诉他们他们在哪个组
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import android.R.anim;
import android.R.bool;
import android.R.string;
import android.renderscript.Int2;
public class Human {
\t //Property
\t String Fname;
\t String Lname;
\t boolean Gender;
\t Date Birthday;
\t int Age;
\t
\t //Method
\t public Human() {
\t \t // TODO Auto-generated constructor stub
\t }
\t
\t //Get Age of a Person
\t public Date GetAge (Date c){
\t \t
\t \t SimpleDateFormat dfDate = new SimpleDateFormat("dd/MM/yyyy");
\t \t java.util.Date C = null;
\t \t java.util.Date B = null;
\t \t Calendar cal = Calendar.getInstance();
\t \t try
\t \t {
\t \t \t c = dfDate.parse("01/1/2016");
\t \t \t B = dfDate.parse(dfDate.format(cal.getTime()));
\t \t \t return B;
\t \t \t
\t \t }catch (java.text.ParseException e)
\t \t {
\t \t \t e.printStackTrace();
\t \t }
\t \t
\t \t int difDays = (int) ((c.getTime() - B.getTime())/(1000*60*60*24));
\t \t System.out.println(difDays);
\t \t return B;
\t \t
\t
\t \t
\t \t
\t }
\t
\t
\t //Get Group of a Person
\t
\t public String GetGroup(int Age)
\t {
\t \t
\t \t if (Age >= 1 && Age <= 10) {
\t \t \t
\t \t \t return ("child");
\t \t \t
\t \t \t
\t \t }
\t \t
\t \t else if (Age >= 11 && Age <= 45) {
\t \t \t
\t \t \t \t \t \t \t
\t \t \t \t return ("young");
\t \t }
\t \t
\t \t
\t \t else if (Age >= 45) {
\t \t \t
\t \t \t return ("old");
\t \t }
\t \t
\t \t
\t \t return toString() ;
\t \t
\t \t \t \t
\t }
\t
\t
\t
\t
\t
}
你是什么意思“我不知道回报应该是什么”呢?你测试了你的部分代码吗? – Derlin