Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1.  
  2. public class car {
  3.  
  4. private String name ;
  5. private int id ;
  6. private int seatNo;
  7. private int year;
  8. private carelement[]arrel;
  9. private int nb;
  10.  
  11. public car(String nn ,int ii ,int ss , int yy , int size)
  12. {
  13. nn = name;
  14. ii = id;
  15. ss = seatNo;
  16. yy = year;
  17. arrel = new carelement[size];
  18. nb = 0;
  19. }
  20. public void display()
  21. {
  22. System.out.println("the car`s name is : "+name);
  23. System.out.println("the car`s id is : "+id);
  24. System.out.println("the car`s seatNo is : "+seatNo);
  25. System.out.println("the car`s year is : "+year);
  26. for(int i=0 ; i<nb ; i++)
  27. arrel[i].display();
  28. }
  29. public boolean addelement(carelement el)
  30. {
  31. if(nb<arrel.length)
  32. {
  33. arrel[nb++] = new carelement(el);
  34. return true;
  35. }
  36. else
  37. return false;
  38. }
  39. public double carprice()
  40. {
  41. double sum = 0;
  42. for(int i=0 ; i<nb ; i++)
  43. sum += arrel[i].getPrice();
  44. return sum;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement