Friday, October 13, 2017

Assignment 01

Assignment 01


Author: A. El-Gadi/Faculty of Computer Engineering/Tripoli University

A simplified cup can be modeled as a cylinder of uniform thickness and a base that has the same thickness. Both the cylinder and the base are made of the same material, which is given by its density. The cup can be filled with a certain amount of liquid -again given by its density-, and a certain amount of the liquid can be poured out of the cup. There should be a function to get the tare of the cup, a function to get the weight of the liquid in the cup and a function to get the overall weight of the cup and the liquid. There, should also be a function to fill the cup with a certain amount of liquid and a function to pour a certain amount of liquid. If the amount of liquid is not specified when filling the cup, the cup should be filled to the brim, and if the amount of liquid to be poured is not specified the cup should be emptied. When created a cup should be empty, but it can also be created with a certain amount of liquid in it. Write a class that captures the concept of a glass as described above making sure to disallow any illogical and inconsistent values for the different variables and parameters in your class.

Assignment due on Tuesday, October 17, 2017

7 comments:

  1. "a certain amount of the liquid can be poured out of the cup."
    what if the amount specified by the user exceeds the amount that actually exists in the cup? empty the cup or consider it a logical error and leave the content of the cup?

    ReplyDelete
    Replies
    1. Both solutions are plausible. Good thinking!

      Delete
  2. هل مطلوب منا نحطو ارقام في main
    يعني مجرد claa !!

    ReplyDelete
  3. member variables of the class excluding density
    the User will assign it or the Programmer
    is it necessary to write setfunctions to those variables ?

    ReplyDelete
    Replies
    1. The user of the class, who is also a programmer, should be free to assign his own values as long as they are logical and consistent. Set functions would help a lot in checking for the validity of data.

      Delete
  4. This comment has been removed by the author.

    ReplyDelete