* You will need the following method to get an integer represented as a string type. The needed header files for your co

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

* You will need the following method to get an integer represented as a string type. The needed header files for your co

Post by answerhappygod »

You Will Need The Following Method To Get An Integer Represented As A String Type The Needed Header Files For Your Co 1
You Will Need The Following Method To Get An Integer Represented As A String Type The Needed Header Files For Your Co 1 (47.26 KiB) Viewed 77 times
Rewrite the following OOP Java code as an OOP C++ code.
:
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(); }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply