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
"a certain amount of the liquid can be poured out of the cup."
ReplyDeletewhat 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?
Both solutions are plausible. Good thinking!
Deleteهل مطلوب منا نحطو ارقام في main
ReplyDeleteيعني مجرد claa !!
main() is not required.
Deletemember variables of the class excluding density
ReplyDeletethe User will assign it or the Programmer
is it necessary to write setfunctions to those variables ?
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.
DeleteThis comment has been removed by the author.
ReplyDelete