Exercise P5.18. Design a class House that defines a house on a street

profileThehonest
 (Not rated)
 (Not rated)
Chat

Exercise P5.18. Design a class House that defines a house on a street. A house has a house number and an (x, y) location, where x and y are numbers between –10 and 10. The key member function is plot, which plots the house.
Next, design a class Street that contains a number of equally spaced houses. An object of type Street stores the first house, the last house (which can be anywhere on the screen), and the number of houses on the street. The Street::plot function needs to make the intermediate house objects on the fly, because you don’t yet know how to store an arbitrary number of objects.
Use these classes in a graphics program in which the user clicks with the mouse on the locations of the first and last house, then enters the house numbers of the first and last house, and the number of houses on the street. Then the entire street is plotted.


    • 10 years ago
    A+ Work
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      drawhouse.zip