This exercise is reserved for pair programming in the live lab sessions.
Please skip it when doing the exercises individually.
In this exercise, you will write a program DateFashion containing a static method dateFashion() with the following signature:
public static int dateFashion(int you, int date)
You and your date are trying to get a table at a restaurant. The parameter you is the stylishness of your clothes, in the range 0..10, and date is the stylishness of your date’s clothes. The result ‘getting the table’ is encoded as an int value where 0 = no, 1 = maybe, 2 = yes.
If either of you is very stylish, that is, 8 or more, then the result is 2 (yes), except that if either of you has style of 2 or less, then the result is 0 (no). Otherwise the result is 1 (maybe). Here are some examples of evaluating the method on representative input values:
dateFashion(5, 10) -> 2 dateFashion(5, 2) -> 0 dateFashion(5, 5) -> 1
As in the preceding exercise, add a main() method which will take int values from the command-line and pass them to the method dateFashion(). You can assume that only two values will be supplied, and that they are in the range 0..10. Example outputs are as follows:
: java DateFashion 5 10 2 : java DateFashion 5 2 0 : java DateFashion 5 5 1
An automated test has been created for this exercise: DateFashionTest.java.