* You will need the following method to get an integer represented as a string type. The needed header files for your co
Posted: Sat Nov 27, 2021 2:35 pm
:
package q3;
public class Accommodation{
private int noOfBedrooms = 1;
private String ownerName;
public Accommodation(){
ownerName = "No name";
}
public Accommodation(int noOfBedrooms, String ownerName){
this.noOfBedrooms = noOfBedrooms;
this.ownerName = ownerName;
}
public void setOwnerName(String ownerName){
this.ownerName = ownerName;
}
public String toString(){
return "noOfBedrooms=" + noOfBedrooms +", ownerName="+
ownerName;
}
}
package q3;
public class Apartment extends Accommodation{
private int floorNo; public Apartment(){
}
public Apartment(int noOfBedrooms, String ownerName, int
floorNo){
super(noOfBedrooms, ownerName);
this.floorNo = floorNo;
}
public String toString(){
return super.toString()+", floorNo=" + floorNo;
}
}
package q3;
public class App{
public static void main(String[] args){
Accommodation acc1 = new Accommodation();
acc1.setOwnerName("Huda");
System.out.println(acc1.toString());
Apartment acc2 = new Apartment(3,"Ahmed", 45);
System.out.println(acc2.toString());
}
}
* You will need the following method to get an integer represented as a string type. The needed header files for your code are also given. #include <iostream> #include <string> #include <sstream> using namespace std; string intToString (int number) { ostringstream ss; SS << number; return ss.str(); }