Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class car {
- private String name ;
- private int id ;
- private int seatNo;
- private int year;
- private carelement[]arrel;
- private int nb;
- public car(String nn ,int ii ,int ss , int yy , int size)
- {
- nn = name;
- ii = id;
- ss = seatNo;
- yy = year;
- arrel = new carelement[size];
- nb = 0;
- }
- public void display()
- {
- System.out.println("the car`s name is : "+name);
- System.out.println("the car`s id is : "+id);
- System.out.println("the car`s seatNo is : "+seatNo);
- System.out.println("the car`s year is : "+year);
- for(int i=0 ; i<nb ; i++)
- arrel[i].display();
- }
- public boolean addelement(carelement el)
- {
- if(nb<arrel.length)
- {
- arrel[nb++] = new carelement(el);
- return true;
- }
- else
- return false;
- }
- public double carprice()
- {
- double sum = 0;
- for(int i=0 ; i<nb ; i++)
- sum += arrel[i].getPrice();
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement