fork(2) download
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Ferry {
  7.  
  8. public static void main(String[] args)
  9. {
  10.  
  11. Scanner input = new Scanner(System.in);
  12. int numberOfTestcases = input.nextInt();
  13. double ferryLength = input.nextInt();
  14. int numberOfCars = input.nextInt();
  15. double carLength = input.nextInt();
  16. String carStartSide = input.next();
  17.  
  18. List<Car> ferry = new ArrayList<Car>();
  19. Car cr = new Car();
  20. ferry.add(cr);
  21.  
  22. List<Car> boatArray = new ArrayList<Car>();
  23.  
  24. double lengthCarOnFerry = 0;
  25. int count = 0;
  26.  
  27. while(true)
  28. {
  29. if((count % 2) == 0) // You are on the left side
  30. {
  31. for(int i = 0; i < ferry.size(); i++)
  32. {
  33. if(lengthCarOnFerry <= ferryLength && cr.getSide() == "left") // If any car are on the left side
  34. {
  35. if(ferry.size() > numberOfCars)
  36. {
  37. }
  38. else
  39. {
  40. boatArray.add(ferry.get(i)); // Add it to the boatarray
  41. break;
  42. }
  43. }
  44.  
  45. }
  46. }
  47.  
  48. else // You are on the right side
  49. {
  50. for(int i = 0; i < ferry.size(); i++)
  51. {
  52. if(lengthCarOnFerry <= ferryLength && cr.getSide() == "right") // If any car are on the right side
  53. {
  54. boatArray.add(ferry.get(i)); // Add it to the boatarray
  55. }
  56.  
  57. }
  58.  
  59. break;
  60. }
  61.  
  62. count++;
  63. }
  64.  
  65. System.out.println(count);
  66. }
  67.  
  68. }
  69.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:6: error: class Ferry is public, should be declared in a file named Ferry.java
public class Ferry {
       ^
Main.java:18: error: cannot find symbol
		List<Car> ferry = new ArrayList<Car>();
		     ^
  symbol:   class Car
  location: class Ferry
Main.java:18: error: cannot find symbol
		List<Car> ferry = new ArrayList<Car>();
		                                ^
  symbol:   class Car
  location: class Ferry
Main.java:19: error: cannot find symbol
		Car cr = new Car();
		^
  symbol:   class Car
  location: class Ferry
Main.java:19: error: cannot find symbol
		Car cr = new Car();
		             ^
  symbol:   class Car
  location: class Ferry
Main.java:22: error: cannot find symbol
		List<Car> boatArray = new ArrayList<Car>();
		     ^
  symbol:   class Car
  location: class Ferry
Main.java:22: error: cannot find symbol
		List<Car> boatArray = new ArrayList<Car>();
		                                    ^
  symbol:   class Car
  location: class Ferry
7 errors
stdout
Standard output is empty