fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class AbstractClass {
  9.  
  10. abstract class Vessel {
  11. double contents;
  12. abstract double capacity();
  13. void fill(double amount) {
  14. contents = Math.min(contents + amount, capacity());
  15. }
  16. }
  17.  
  18. class Tank extends Vessel {
  19.  
  20. double length, width, height;
  21.  
  22. Tank(double length, double width, double height) {
  23. this.length = length;
  24. this.width = width;
  25. this.height = height;
  26. }
  27.  
  28. double capacity() {
  29. return length * width * height;
  30. }
  31.  
  32. public String toString() {
  33. return "tank (" + length + ", " + width + ", " + height + ")";
  34. }
  35. }
  36.  
  37. class Cube extends Tank {
  38.  
  39. Cube(double side) {
  40. super(side, side, side);
  41. }
  42.  
  43. public String toString() {
  44. return "cube (" + length + ")";
  45. }
  46. }
  47.  
  48. class Barrel extends Vessel {
  49. double radius, height;
  50.  
  51. Barrel(double radius, double height) {
  52. this.radius = radius;
  53. this.height = height;
  54. }
  55.  
  56. double capacity() {
  57. return height * Math.PI * radius * radius;
  58. }
  59.  
  60. public String toString() {
  61. return "barrel (" + radius + ", " + height + ")";
  62. }
  63. }
  64. }
Compilation error #stdin compilation error #stdout 0.04s 4386816KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty