Question: Need help in this project CS 116 Programming Project l Due to be submitted in moodle by your lab class 9/13 or 9/14 The Water
Need help in this project
CS 116 Programming Project l Due to be submitted in moodle by your lab class 9/13 or 9/14 The Water Jug Riddle (AKA The Die Hard Riddle) This is a problem that is prominently featured in the film Die Hard With a Vengeance https://www.youtube.com/watch?v 6cAbgAaEOVE&t-17s You have a 3-gallon and a 5-gallon jug that you can fill from a fountain of water. The problem is to fill one of the jugs with exactly 4 gallons of water. How do you do it? Programming Problem: define a C++ Bucket class with the following methods: Bucket () constructor that takes two parameters, a string name and an int parameter, the bucket capacity print) takes no paramers. Prints the bucket name, capacity and contents. Returns void fill) that takes no parameters, fills the bucket to capacity. Returns void empty) that takes no parameters, empties the bucket. Returns void -pour into) takes one parameter, a reference to a Bucket object, returns an int that is the number of gallons transferred. This method pours the calling object Bucket into the parameter object bucket. As much of the first bucket as will fin into the remaining capacity of the parameter bucket is transferred. The class will have thee private data members, name, capacity and contents Capacity is the size of the bucket, and contents is the amount of water the bucket currently contains
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
