fork download
  1. package testovoe_zadanie;
  2.  
  3. /*Аквариум. Определить иерархию рыб и рептилий. Создать аквариум. Посчитать
  4.  
  5. общую цену вместе со стоимостью аксессуаров.*/
  6.  
  7. public class Aquarium {
  8. protected double price = 0;
  9. protected double weight = 0;
  10.  
  11. private static double totalPrice = 0;
  12.  
  13. public Aquarium(double price, double weight) {
  14. this.price = price;
  15. this.weight = weight;
  16. totalPrice += this.price;
  17. }
  18.  
  19. public Aquarium() {
  20. }
  21.  
  22. public Aquarium(double price) {
  23. this.price = price;
  24. totalPrice += this.price;
  25. }
  26.  
  27. public static double getTotalPrice()
  28. {
  29. return totalPrice;
  30. }
  31.  
  32. public static void main(String[] args) {
  33.  
  34. Aquarium ob1 = new Aquarium(2, 5);
  35. Aquarium ob2 = new Aquarium(3, 5);
  36. Aquarium ob3 = new Aquarium(5, 5);
  37. Aquarium ob4 = new Aquarium();
  38. Aquarium ob5 = new Aquarium(5);
  39.  
  40. Fish fish1 = new Fish(2, 5, "Рыбка1");
  41. Fish fish2 = new Fish(2, 5);
  42. Fish fish3 = new Fish();
  43. Fish fish4 = new Fish(5);
  44.  
  45. Reptile reptile1 = new Reptile(5);
  46.  
  47. Accessory accessory1 = new Accessory(63.5, 2, "Лампа");
  48.  
  49. System.out.println("Общая стоимость " + getTotalPrice());
  50. }
  51.  
  52. }
  53.  
  54.  
  55. package testovoe_zadanie;
  56.  
  57. public class Fish extends Aquarium {
  58. String nameOfFish;
  59.  
  60. public Fish(double price, double weight, String nameOfFish) {
  61. super(price, weight);
  62. }
  63.  
  64. public Fish(double price, double weight) {
  65. super(price, weight);
  66. }
  67.  
  68. public Fish() {
  69.  
  70. }
  71.  
  72. public Fish(double price) {
  73. super(price);
  74. }
  75.  
  76. public Fish(double price, String nameOfFish) {
  77. super(price);
  78. }
  79. }
  80.  
  81.  
  82. package testovoe_zadanie;
  83.  
  84. public class Reptile extends Aquarium {
  85. String nameOfReptile;
  86.  
  87. public Reptile(double price, double weight, String nameOfReptile) {
  88. super(price, weight);
  89. }
  90.  
  91. public Reptile(double price, double weight) {
  92. super(price, weight);
  93. }
  94.  
  95. public Reptile() {
  96.  
  97. }
  98.  
  99. public Reptile(double price) {
  100. super(price);
  101.  
  102. }
  103. }
  104.  
  105.  
  106. package testovoe_zadanie;
  107.  
  108. public class Accessory extends Aquarium {
  109. String nameOfAccessory;
  110.  
  111. public Accessory(double price, double weight, String nameOfAccessory) {
  112. super(price, weight);
  113. }
  114.  
  115. public Accessory(double price, double weight) {
  116. super(price, weight);
  117. }
  118.  
  119. public Accessory() {
  120.  
  121. }
  122.  
  123. public Accessory(double price) {
  124. super(price);
  125. }
  126.  
  127. public Accessory(double price, String nameOfAccessory) {
  128. super(price);
  129. }
  130. }
  131.  
  132.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:55: error: class, interface, or enum expected
package testovoe_zadanie;
^
Main.java:82: error: class, interface, or enum expected
package testovoe_zadanie;
^
Main.java:106: error: class, interface, or enum expected
package testovoe_zadanie;
^
3 errors
stdout
Standard output is empty