Homework 4, Task 4

Stumpf.Alex
Nerd
Nerd
Beiträge: 644
Registriert: 1. Okt 2007 12:40
Wohnort: Darmstadt
Kontaktdaten:

Homework 4, Task 4

Beitrag von Stumpf.Alex »

I think the excerise doesn't points out which things we are allowed to change. There is only the "contract" to preserve the features. Should this mean we are free to change ALL (including the contracts) with respect to preserve these features and having a desgin which complies the modified contracts in the end?

best wishes

Benutzeravatar
sproksch
Computerversteher
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Re: Homework 4, Task 4

Beitrag von sproksch »

Yes.

mazbu
Mausschubser
Mausschubser
Beiträge: 44
Registriert: 23. Nov 2008 23:44

Re: Homework 4, Task 4

Beitrag von mazbu »

Do I have to make all the test succed with the modified design? Because I don't think we can withdraw 60 from JuniorCheckingAccount.

Benutzeravatar
sproksch
Computerversteher
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Re: Homework 4, Task 4

Beitrag von sproksch »

You have to ensure that all features offered by the different account types are meaningful tested. In the case of a JuniorCheckingAccount it is a good idea to check if a withdrawal of 60 results in an exception.

If this helps you: You are allowed to alter the tests or split them into multiple files.

Senchy
Windoof-User
Windoof-User
Beiträge: 37
Registriert: 6. Okt 2010 19:14

Re: Homework 4, Task 4

Beitrag von Senchy »

An additional question to this task:
is this template correct?

Code: Alles auswählen

/**
     * Sets the line of credit for this account.
     * 
     * @see #close() for additional constraints.
     * 
     * @REQUIRE balance >= -lineOfCredit
     * @ENSURE newValue must be positive
     */
    @Requires({ "getBalance() >= (-getLineOfCredit())" })
    public void setLineOfCredit(final int newValue);
I would assume somthing like:

Code: Alles auswählen

/**
     * Sets the line of credit for this account.
     * 
     * @see #close() for additional constraints.
     * 
     * @REQUIRE balance >= -lineOfCredit
     * @REQUIRE newValue must be positive
     */
    @Requires({ "getBalance() >= (-getLineOfCredit())","newValue > 0" })
    public void setLineOfCredit(final int newValue);
best regards

Benutzeravatar
sproksch
Computerversteher
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Re: Homework 4, Task 4

Beitrag von sproksch »

Yes, you are absolutely correct. You just found a perfect example of a rotten comment. ;)

Antworten

Zurück zu „Archiv“