Hi!
please help me whit this code, my program is working
please look at it.
The program has one super
class(vehcile) and 2 sub classes( MotorVehcile and car).
class vehcile:
variable: woner
metod: - print() and -newWoner
class MotorVehcile
variable:woner, power
metod:newpower,print
class car:
variable:woner,power,regNe
metod:new Register number, print
----------------------------------------------
class
Test: is like this
public static void main(
String[] arg) {
Car c= new Car("Alex", 500,"ABC 200");
c.print();
c.NewWoner();
c.print();
c.newPower();
c.print();
c.newRegNr();
c.print();
Here we have called 3 methods(newWoner, newPower,newRegNr)
and we(users) give new value to every
attribute(I have already written this). and the print methods print out an objects all
attributes.finally the program looks like this.
I have written the program,it is ok.but when I run the program the out put is different(not as same as the orignal):
the problem is here I must not change Class Test and the same time I must not add new methods.
The first time when the program asks user: write new woner(ex: peter)
The usre writes new owner and the program prints out first the old woner(Alex), power and regnNr and then new woner.
every time when we call a method the program should print out every thing from beginning.Like this:
//(The orignla print out after running the program looks like this
// How can I silove this problem.
woner : Alex
power : 500
regnbr:ABC 200
write new woner

the user put in new woners name)

eter
//After calling new Woner the program prints out every thig from beginning.
woner : Alex
power :500
regnbr:ABC 200
write new woner: peter
woner : peter
power :500
regnbr:ABC 200
write new Power

the user put in new power ): 20000
//After calling new power the program prints out every thig from beginning.
woner : Alex
power :500
regnbr:ABC 200
write new woner: peter
woner : peter
power :500
regnbr:ABC 200
write new Power: 20000
woner : peter
power : 20000
regnbr:ABC 200
write new regNr

the user put in new regNr):
//After calling new regNr the program prints out every thig from beginning.
woner : Alex
power :500
regnbr:ABC 200
..........
..........