The tester i wrote for this code wont work. Need help to write a tester class. w
ID: 3527712 • Letter: T
Question
The tester i wrote for this code wont work. Need help to write a tester class. will give 5 star rating. class ship { string name; int year; public: ship(string s,int y) { name=s; year=y; } void getData(string s,int y) { name = s; year = y; } void toString() { system.out.println("Name :-"+name+"and year built :-" + year); } bool equals(ship s1) { if(s1.name.equals(this.name)) if(s1.year == this.year) return true; return false; } class Cruiseship extends ship { long maxPas; Cruiseship(String s,int y,int x) { maxPas = x,name = s,year = y; } void setData(String s,int y,int x) { maxPas = x,name = s,year = y; } void toString() { system.out.println("Name: "name+" Year : "+year +"number of passengers: "+maxPas); } bool equals(Cruiseship s1) { if(s1.name.equals(this.name)) if(s1.year == this.year) if(s1.maxPas==this.maxPas) return true; return false; return false; } } class Cargoship extends ship { int capacity; Cargoship(String s,int y,int x) { capacity = x,name = s, year = y; } void toString() { system.out.println(name); system.out.println(year); system.out.println(capacity); } void setData(String s,int y,int x) { capacity = x,name = s,year = y; } bool equals(Cargoship s1) { if(s1.name.equals(this.name)) if(s1.year == this.year) if(s1.capacity==this.capacity) return true; return false; return false; } }Explanation / Answer
//I can see that your program has lots of issues especially for a class. //Note the scope of the program above is off and that each class must be in their own file by the same name as the class //below is a tester program for the same assignment, //package shipExtending is my package where all 3 class files are included in //my accessor/mutators/private membes have slightly different names than the above https://www.dropbox.com/s/ne0ad3aeetv7n50/ShipTester.txt rate and comment and I will unhost
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.