abstract class Vessel { double contents; abstract double volume(); abstract double circumf(); public void fill(double amount) { contents = contents + amount; contents = Math.min(contents, volume()); } } class Tank extends Vessel { double length, width, height; Tank(double length, double width, double height) { this.length = length; this.width = width; this.height = height; } double volume() { return length * width * height; } double circumf() { return 2 * (width + length); } } class Barrel extends Vessel { double radius, height; Barrel(double radius, double height) { this.radius = radius; this.height = height; } double volume() { return height * Math.PI * radius * radius; } double circumf() { return 2 * Math.PI * radius; } } public class Vessel9 { public static void main(String[] args) { Vessel v1 = new Tank(15, 9, 12); Vessel v2 = new Barrel(2.5, 8); v1.fill(100); System.out.println("Indhold af v1 = " + v1.contents); v1.fill(2000); System.out.println("Indhold af v2 = " + v1.contents); v2.fill(500); System.out.println("Indhold af v2 = " + v2.contents); } }