Design a class named Box whose dimensions are integers and private to the class [closed]Array-like container...

Travelling outside the UK without a passport

Fear of getting stuck on one programming language / technology that is not used in my country

What should you do if you miss a job interview (deliberately)?

Why did the EU agree to delay the Brexit deadline?

New brakes for 90s road bike

Redundant comparison & "if" before assignment

Why electric field inside a cavity of a non conducting not zero

Can disgust be a key component of horror?

What will be next at the bottom row and why?

Is there a RAID 0 Equivalent for RAM?

What is Cash Advance APR?

Lowest total scrabble score

What if a revenant (monster) gains fire resistance?

How could a planet have erratic days?

Creating nested elements dynamically

Rising and falling intonation

What does chmod -u do?

How to implement a feedback to keep the DC gain at zero for this conceptual passive filter?

What does routing an IP address mean?

Are Captain Marvel's powers affected by Thanos' actions in Infinity War

Does Doodling or Improvising on the Piano Have Any Benefits?

How can "mimic phobia" be cured or prevented?

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

How can I block email signup overlays or javascript popups in Safari?



Design a class named Box whose dimensions are integers and private to the class [closed]


Array-like container for uints shorter than 8 bits (Rev 1)Converting Ocean to RunLengthEncoding objectRule of 5 - C++11Hackerrank Box ItBinary Search Tree implementation (OOP/classic pointers)OOP modelling of a car agencyProtected Pointer: a unique_ptr wrapper that auto encrypts and decrypts data in memoryPrimitive ArrayList ImplementationArea calculator for shapes as an OOP interview testC++ Updated Stack Code













-2












$begingroup$


Design a class named Box whose dimensions are integers and private to the class.




The dimensions are labelled: length l, breadth b, and height h.

The default constructor of the class should initialize l, b and h to 0.

The parameterized constructor Box (int length, int breadth, int height) should initialize Box's l, b and h to length, breadth and height.

The copy constructor Box(Box B) should set l, b and h and to B's l, b and h respectively.



Apart from the above, the class should have functions:



int getLength() - Return box's length
int getBreadth() - Return box's breadth
int getHeight() - Return box's height
long long CalculateVolume() - Return the volume of the box


Overload the < operator for the class Box. Box A Box B if:



A.l<B.l 
A.b<B.b and A.l==B.l
A.h<B.h and A.b==B.b and A.l==B.l
Overload << operator for the class Box.


If B is an object of class Box:



cout<<B should print B.l, B.b and B.h on a single line separated by commas.



Constraints




  • $0 leq 𝑙, 𝑏, ℎ leq 104$

  • Two boxes being compared using the operator will not have all three dimensions equal.




My Code



int main()
{
int n;
cin>>n;
Box temp;
for(int i=0;i<n;i++)
{
int type;
cin>>type;
if(type ==1)
{
cout<<temp<<endl;
}
if(type == 2)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
temp=NewBox;
cout<<temp<<endl;
}
if(type==3)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
if(NewBox<temp)
{
cout<<"Lessern";
}
else
{
cout<<"Greatern";
}
}
if(type==4)
{
cout<<temp.CalculateVolume()<<endl;
}
if(type==5)
{
Box NewBox(temp);
cout<<NewBox<<endl;
}
}
}









share|improve this question











$endgroup$



closed as off-topic by yuri, Mast, Toby Speight, Zeta, Vogel612 Mar 14 at 18:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Zeta, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2




    $begingroup$
    Could you at least try to properly indent the code?
    $endgroup$
    – Mast
    Mar 14 at 17:46






  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
    $endgroup$
    – Zeta
    Mar 14 at 18:34










  • $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Vogel612
    Mar 14 at 18:35
















-2












$begingroup$


Design a class named Box whose dimensions are integers and private to the class.




The dimensions are labelled: length l, breadth b, and height h.

The default constructor of the class should initialize l, b and h to 0.

The parameterized constructor Box (int length, int breadth, int height) should initialize Box's l, b and h to length, breadth and height.

The copy constructor Box(Box B) should set l, b and h and to B's l, b and h respectively.



Apart from the above, the class should have functions:



int getLength() - Return box's length
int getBreadth() - Return box's breadth
int getHeight() - Return box's height
long long CalculateVolume() - Return the volume of the box


Overload the < operator for the class Box. Box A Box B if:



A.l<B.l 
A.b<B.b and A.l==B.l
A.h<B.h and A.b==B.b and A.l==B.l
Overload << operator for the class Box.


If B is an object of class Box:



cout<<B should print B.l, B.b and B.h on a single line separated by commas.



Constraints




  • $0 leq 𝑙, 𝑏, ℎ leq 104$

  • Two boxes being compared using the operator will not have all three dimensions equal.




My Code



int main()
{
int n;
cin>>n;
Box temp;
for(int i=0;i<n;i++)
{
int type;
cin>>type;
if(type ==1)
{
cout<<temp<<endl;
}
if(type == 2)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
temp=NewBox;
cout<<temp<<endl;
}
if(type==3)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
if(NewBox<temp)
{
cout<<"Lessern";
}
else
{
cout<<"Greatern";
}
}
if(type==4)
{
cout<<temp.CalculateVolume()<<endl;
}
if(type==5)
{
Box NewBox(temp);
cout<<NewBox<<endl;
}
}
}









share|improve this question











$endgroup$



closed as off-topic by yuri, Mast, Toby Speight, Zeta, Vogel612 Mar 14 at 18:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Zeta, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2




    $begingroup$
    Could you at least try to properly indent the code?
    $endgroup$
    – Mast
    Mar 14 at 17:46






  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
    $endgroup$
    – Zeta
    Mar 14 at 18:34










  • $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Vogel612
    Mar 14 at 18:35














-2












-2








-2





$begingroup$


Design a class named Box whose dimensions are integers and private to the class.




The dimensions are labelled: length l, breadth b, and height h.

The default constructor of the class should initialize l, b and h to 0.

The parameterized constructor Box (int length, int breadth, int height) should initialize Box's l, b and h to length, breadth and height.

The copy constructor Box(Box B) should set l, b and h and to B's l, b and h respectively.



Apart from the above, the class should have functions:



int getLength() - Return box's length
int getBreadth() - Return box's breadth
int getHeight() - Return box's height
long long CalculateVolume() - Return the volume of the box


Overload the < operator for the class Box. Box A Box B if:



A.l<B.l 
A.b<B.b and A.l==B.l
A.h<B.h and A.b==B.b and A.l==B.l
Overload << operator for the class Box.


If B is an object of class Box:



cout<<B should print B.l, B.b and B.h on a single line separated by commas.



Constraints




  • $0 leq 𝑙, 𝑏, ℎ leq 104$

  • Two boxes being compared using the operator will not have all three dimensions equal.




My Code



int main()
{
int n;
cin>>n;
Box temp;
for(int i=0;i<n;i++)
{
int type;
cin>>type;
if(type ==1)
{
cout<<temp<<endl;
}
if(type == 2)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
temp=NewBox;
cout<<temp<<endl;
}
if(type==3)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
if(NewBox<temp)
{
cout<<"Lessern";
}
else
{
cout<<"Greatern";
}
}
if(type==4)
{
cout<<temp.CalculateVolume()<<endl;
}
if(type==5)
{
Box NewBox(temp);
cout<<NewBox<<endl;
}
}
}









share|improve this question











$endgroup$




Design a class named Box whose dimensions are integers and private to the class.




The dimensions are labelled: length l, breadth b, and height h.

The default constructor of the class should initialize l, b and h to 0.

The parameterized constructor Box (int length, int breadth, int height) should initialize Box's l, b and h to length, breadth and height.

The copy constructor Box(Box B) should set l, b and h and to B's l, b and h respectively.



Apart from the above, the class should have functions:



int getLength() - Return box's length
int getBreadth() - Return box's breadth
int getHeight() - Return box's height
long long CalculateVolume() - Return the volume of the box


Overload the < operator for the class Box. Box A Box B if:



A.l<B.l 
A.b<B.b and A.l==B.l
A.h<B.h and A.b==B.b and A.l==B.l
Overload << operator for the class Box.


If B is an object of class Box:



cout<<B should print B.l, B.b and B.h on a single line separated by commas.



Constraints




  • $0 leq 𝑙, 𝑏, ℎ leq 104$

  • Two boxes being compared using the operator will not have all three dimensions equal.




My Code



int main()
{
int n;
cin>>n;
Box temp;
for(int i=0;i<n;i++)
{
int type;
cin>>type;
if(type ==1)
{
cout<<temp<<endl;
}
if(type == 2)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
temp=NewBox;
cout<<temp<<endl;
}
if(type==3)
{
int l,b,h;
cin>>l>>b>>h;
Box NewBox(l,b,h);
if(NewBox<temp)
{
cout<<"Lessern";
}
else
{
cout<<"Greatern";
}
}
if(type==4)
{
cout<<temp.CalculateVolume()<<endl;
}
if(type==5)
{
Box NewBox(temp);
cout<<NewBox<<endl;
}
}
}






c++ object-oriented






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 at 18:35









Vogel612

21.9k447131




21.9k447131










asked Mar 14 at 17:03









Ammar AhmadAmmar Ahmad

1




1




closed as off-topic by yuri, Mast, Toby Speight, Zeta, Vogel612 Mar 14 at 18:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Zeta, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by yuri, Mast, Toby Speight, Zeta, Vogel612 Mar 14 at 18:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Toby Speight, Zeta, Vogel612

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    $begingroup$
    Could you at least try to properly indent the code?
    $endgroup$
    – Mast
    Mar 14 at 17:46






  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
    $endgroup$
    – Zeta
    Mar 14 at 18:34










  • $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Vogel612
    Mar 14 at 18:35














  • 2




    $begingroup$
    Could you at least try to properly indent the code?
    $endgroup$
    – Mast
    Mar 14 at 17:46






  • 1




    $begingroup$
    Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
    $endgroup$
    – Zeta
    Mar 14 at 18:34










  • $begingroup$
    Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
    $endgroup$
    – Vogel612
    Mar 14 at 18:35








2




2




$begingroup$
Could you at least try to properly indent the code?
$endgroup$
– Mast
Mar 14 at 17:46




$begingroup$
Could you at least try to properly indent the code?
$endgroup$
– Mast
Mar 14 at 17:46




1




1




$begingroup$
Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
$endgroup$
– Zeta
Mar 14 at 18:34




$begingroup$
Welcome to Code Review! Unfortunately, we don't provide code, we review code you've written. Please see our help center for more information.
$endgroup$
– Zeta
Mar 14 at 18:34












$begingroup$
Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
$endgroup$
– Vogel612
Mar 14 at 18:35




$begingroup$
Welcome to Code Review! I'm afraid this question does not match what this site is about. Code Review is about improving existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way! Please see our help center for more information.
$endgroup$
– Vogel612
Mar 14 at 18:35










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...