Question: Problem 4: OOP A Tank represents a container for water. It has two properties: capacity: creating the object. content: the tank the maximum amount the

 Problem 4: OOP A Tank represents a container for water. It
has two properties: capacity: creating the object. content: the tank the maximum

Problem 4: OOP A Tank represents a container for water. It has two properties: capacity: creating the object. content: the tank the maximum amount the tank can hold. This cannot be changed and is set when e e the amount the tank currently holds. This can go up and down from 0 to the capacity of Part A Write a class called Tank using integers for both capacity and content. Write another class called TankRunner that has a main method and will be used to test out your Tank class. Part B When constructing a new Tank, the capacity must always be set and cannot be left blank, but the initial content can be specified or left blank. If the content is not specified, the implied value equals zero. Check any Write the two constructors for class Tank that implement these two initialization scenarios. necessary constraints for capacity and content. Part C Write a toString format method that works as follows: Tank x = new Tank (10); System.out.println (x): Tank y new Tank (10, 9) system.out.println (y) /I outputs [10,01 // outputs [10,91 Note that when printing out an object, Java will automatically call a toString0" method if it has been implemented. Part D Implement a fill0 method that will fill a tank to its capacity. It should work as follows: Tank x-new Tank (10,3) System. out.println (x) x.fill System.out.printin (x) // outputs [10,3 /I outputs [10,101 Part E Implement a pourFromO method that works as follows: Tank x new Tank (10,10) Tank y new Tank (20,15) System. out.println (x + "." + y): y pourFrom(x) // outputs [10,101, [20,15]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!