Advertisement
vvccs

E4_Engine

Nov 7th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Engine {
  4.  
  5.   int speed;
  6.   String model_name;
  7.  
  8.   public void eng_Details(int e_speed, String m_name) {
  9.     speed = e_speed;
  10.     model_name = m_name;
  11.     System.out.println("Model name " + model_name + " Speed " + speed);
  12.   }
  13. }
  14.  
  15. class Tyre extends Engine {
  16.  
  17.   int warranty;
  18.   String company_name;
  19.  
  20.   public void tyre_Details(int t_warranty, String c_name) {
  21.     warranty = t_warranty;
  22.     company_name = c_name;
  23.     System.out.println(
  24.       "\nCompany name " +
  25.       company_name +
  26.       " warranty of tyre(in years)" +
  27.       warranty
  28.     );
  29.   }
  30. }
  31.  
  32. class Door extends Tyre {
  33.  
  34.   int door_no;
  35.  
  36.   public void door_Details(int n_door) {
  37.     door_no = n_door;
  38.     System.out.println("\n No of Doors " + door_no);
  39.   }
  40. }
  41.  
  42. class Car1 {
  43.  
  44.   public static void main(String[] args) {
  45.     Engine e = new Engine();
  46.     Tyre t = new Tyre();
  47.     Door d = new Door();
  48.     e.eng_Details(220, "CLA 45 AMG");
  49.     t.tyre_Details(5, "MRF");
  50.     d.door_Details(2);
  51.   }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement