Hi everyone. I need help in one problem which I want to solve. How to create (connect) a class using data of two other. For example I have this kind of situation:
class Car
private String name;
private int productionYear;
.....
class SpeedCar extend Car
private int maxspeed;
.....
class Audi extend Car
private String colour;
Now I want to create last class named SpeedCarAudi which will take all data from this two up and of cource from class Car. This should be done using interface.
Later in Main I should create objects for Car, SpeedCar, Audi and SpeedCarAudi.
Thanks for any adivse
How to create new class using interface?
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Ксенія Українка
25 August 2020, 03:00
Hi!
We can't create a class using data of two other in java.
+1
Andrzej
25 August 2020, 15:28
This is one of my exercise to do and I thik pewrson who teach me knows that it is possible using interface. He told me there is only one way to do it.
Maybe not using data of other class but using it variable.
0
Ксенія Українка
26 August 2020, 06:11
can you show exercise?
0