50 likes | 219 Views
CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public. it-sudparis.eu /~gibson/Teaching/CSC7322/. The Water Jugs Problem …/~ gibson / Teaching /CSC7322/L14-TheWaterJugsProblem.pdf. A well - known instance of the problem. ??.
E N D
CSC 7322 : Object OrientedDevelopment J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public.it-sudparis.eu/~gibson/Teaching/CSC7322/ The Water JugsProblem …/~gibson/Teaching/CSC7322/L14-TheWaterJugsProblem.pdf TSP: Software Engineering
A well-known instance of the problem ?? 8-5: 3 5 0 5-3: 3 2 3 3-8: 6 2 0 5-3: 6 0 2 8-5: 1 5 2 5-3: 1 4 3 3-1: 4 4 0 FIND A SEQUENCE OF MOVES (NOT NECESSARILY THE SHORTEST) THAT LEADS TO THE DESIRED OUTCOME (OF 4oz MEASURED) TSP: Software Engineering
A ‘Formal’ Description of the Problem • Considerthreejugsthat (when full) measureintegerquantitiesx,y and z. • Startingwith 1 jug full, x say, measuresomequantity q in one of the 3 jugs by making a sequence of valid moves • A valid move pours water from one juginto the next, either: • Emptying the first jug, and perhapsfilling the second; or • Filling the second jug, and perhapsleavingsome water in the first. • Input, x,y,z,q • Output: sequence of moves leaving q in either x, y or z, • or an emptysequencewhen no solution is possible. TSP: Software Engineering
Generalise the Problem Instead of 3 jugs, allow the system to containanynumber of jugs Extend the Problem Add a hose, providing an unlimitedsupply of water thatcanbeused to fillanyjugatany time (between moves) And/or Add a sinkthatcanbeused to emptyanyjugatany time (between moves) and where the water pouredawaycannotberecovered TSP: Software Engineering
Implementing A Solution • Eachstudentis to choose 1 of the above variations, and write code thatmeets the requirements for the variation chosen. • Students are to share as much code as possible for: • Testing • Simulation FUTURE: Wewillre-engineeryour solutions in another OO programminglanguagesotry to makeyour code as good as possible for future ‘users’. TSP: Software Engineering