rage / java-programming

https://java-programming.mooc.fi
521 stars 213 forks source link

part05-part05_13.IdenticalTwins #432

Open Luitenist opened 1 year ago

Luitenist commented 1 year ago

I found this a very confusing exercise. The text gave no clear assignment and stated there were no tests.

The only way I figured out what to do was by submitting the material to the server and receiving (incorrect) test feedback.

Here are test 3, 4 and 5:

test 3: Two persons with a same name but a different birthday should be the same. Try: Person first = new Person("Leevi", new SimpleDate(1, 1, 2017), 70, 10); Person second = new Person("Leevi", new SimpleDate(2, 1, 2017), 70, 10); System.out.println(first.equals(second));

test4: Two persons with a same name but different month of birth should not be the same. Try: Person first = new Person("Leevi", new SimpleDate(1, 1, 2017), 70, 10); Person second = new Person("Leevi", new SimpleDate(1, 2, 2017), 70, 10); System.out.println(first.equals(second));

test5: Two persons with same name but different year of birth should not be the same. Try: Person first = new Person("Leevi", new SimpleDate(1, 1, 2017), 70, 10); Person second = new Person("Leevi", new SimpleDate(1, 1, 2018), 70, 10); System.out.println(first.equals(second));

In fact, test 3 only passes if day is not the same:

//past test 4
       if (nameFlag && monthFlag && yearFlag && heightFlag && weightFlag && dayFlag) {
            //Two persons with a same name but a different birthday should be the same.
            return true;
        } if (nameFlag && monthFlag && yearFlag && heightFlag && weightFlag) {
//pass test 3            
            return false;
        }

        else {
            return false;
        }

forgive the awkward code ;)