week04.pdf - Lab Practice Week 4 For this lab you must submit Source code of your answers to all exercises to moodle This is due by the beginning of

week04.pdf - Lab Practice Week 4 For this lab you must...

This preview shows page 1 out of 1 page.

Lab Practice Week 4 Today’s work builds on the fraction class which you produced for question 3 in Week 3’s lab practice.1. Change your fraction class so that its instance variables numerator and denominatorare hidden (i.e. private). Check that your old client class will not now compile (i.e, if the Fraction class instance variable name ‘numerator’was used in the client class). 2. Add a public method isZeroto your fraction class for testing whether the callingfraction is equal to the number zero. Modify your old client class so that it now loops until a fraction representing zero is entered. 3. Add two more public methods: equals which determines whether two fractionsrepresent the same number and addwhich adds another fraction to the calling fraction and returns a fraction result. Make a client which loops around getting two fractions
Background image

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture