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. class Car{
  8. //pola
  9. private double fuelEfficiency, fuelLevel, fuelCost, lastFuelChange;
  10. //konstruktor
  11. public Car(double fuelEfficiency){
  12. this.fuelEfficiency = fuelEfficiency;
  13. fuelLevel = 0;
  14. }
  15. //metody
  16. void drive(double distance){
  17. if(fuelLevel < distance / fuelEfficiency){
  18. System.out.println("Not enough fuel.");
  19. }else{
  20. System.out.println("Driving " + distance + "miles...");
  21. lastFuelChange = distance / fuelEfficiency;
  22. fuelLevel -= lastFuelChange;
  23. }
  24. }
  25.  
  26. double convertToLitres(double gallons){
  27. return gallons * 4.546;
  28. }
  29.  
  30. double getFuel(){
  31. return fuelLevel;
  32. }
  33.  
  34. void addFuel(double quantity){
  35. System.out.println("Adding " + quantity + " gallons of fuel...");
  36. fuelLevel += quantity;
  37. lastFuelChange = quantity;
  38. }
  39.  
  40. double fuelCost(){
  41. return lastFuelChange;
  42. }
  43.  
  44. double getCost(){ // tego trochÄ™ nie rozumiem, "returns the cost of fuel in pounds and pence"? zwracam koszt w funtach.
  45. return 1.359;
  46. }
  47. }
  48.  
  49. class Ideone
  50. {
  51. public static void main (String[] args) throws java.lang.Exception
  52. {
  53. // your code goes here
  54. }
  55. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
Standard output is empty