I want to use a method, which takes for example an int and also returns an integer.
For example, if the the given integer is strong return a, if it is notstrong return b.
How would you write that in a Code?
I want to use that in a more general way.
I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.
mlong should return an int depending on the X.moth.
at the moment my code looks like this:
// File1:
public class date {
public int day;
public int month;
public int year;
}
// File 2:
public class monthlength {
public int mlong(date X) {
int t;
t = X.month;
if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12)
{ return 31; }
if(t == 4 || t == 6 || t == 9 || t == 11)
{return 30;}
}
}
Can plz someone help me and point out how to fix this?