Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1.  
  2. public class BusTest {
  3.  
  4. public static void main(String[] args) {
  5. Bus b1, b2, b3;
  6. //b1 = new Bus();
  7. //b2 = new Bus();
  8. b3 = new Bus("Dhaka Chaka", 30, 6000, "Gazipur", "Mirpur");
  9.  
  10. /*b1.name = "Bolaka";
  11. b1.seatCount = 25;
  12. b1.engineCapacity = 3000;
  13. b1.source = "Gazipur";
  14. b1.destination = "Jatrabari";
  15.  
  16. b2.name = "Projapoti";
  17. b2.seatCount = 35;
  18. b2.engineCapacity = 3200;
  19. b2.source = "Tongi";
  20. b2.destination = "Shyamoli";
  21.  
  22. System.out.println("Bus 1:");
  23. System.out.println("Name: " + b1.name);
  24. System.out.println("Seat Count: " + b1.seatCount);
  25. System.out.println("Engine Capacity: " + b1.engineCapacity);
  26. System.out.println("Source: " + b1.source);
  27. System.out.println("Destination: " + b1.destination);*/
  28.  
  29. System.out.println("\nBus 2:");
  30. System.out.println("Name: " + b3.name);
  31. System.out.println("Seat Count: " + b3.seatCount);
  32. System.out.println("Engine Capacity: " + b3.engineCapacity);
  33. System.out.println("Source: " + b3.source);
  34. System.out.println("Destination: " + b3.destination);
  35. }
  36.  
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. public class Bus
  48. {
  49. {
  50. String name;
  51. int seatCount;
  52. int engineCapacity;
  53. String source;
  54. String destination;
  55. }
  56.  
  57. public Bus()
  58. {
  59.  
  60. }
  61.  
  62. public Bus(String name, int seatCount, int engineCapacity, String source, String destination)
  63. {
  64. this.name = name;
  65. this.seatCount = seatCount;
  66. this.engineCapacity = engineCapacity;
  67. this.source = source;
  68. this.destination = destination;
  69. }
  70.  
  71. @Override
  72. public String toString()
  73. {
  74. return "Name: " +this.name;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement