Oct 17, 2017 at 11:56pm UTC
I have 70 perecent of the project coded out but i just need help asking the user for each specific function. here are the instructions for further understanding
write a program and call it BoxProject. Besides the file containing main() function there should be two other classes each in its own pair of files; that is a *.h and a *.cpp file. one of these classes should be a class called MenuClass, and the other should be a class called Box. There should be a user loop in the main() function that invokes the MenuClass member-function DisplayMenu() and so forth. The Menu should allow the user to specidy as well as change, the dimesions of a box, that is length (L) width(W) and height (H). There should be a print() memeber function. The Menu should also allow the user to calculate the volume (v) of an instance of the box class. the program should have a single box object.
Box.cpp
#include "stdafx.h"
#include "Box.h"
#include <iostream>
using namespace std;
// ============
// Constructors
// ============
// ========================
// Default Constructor Cube
// ========================
Box::Box(void) {
edgeLength = 0;
} // Constructor Cube
// ======================
// ================================
// Non-Default Constructor Number()
// ================================
Box::Box(double x){
edgeLength = x;
} // Constructor Cube
// ======================
// ================
// End Constructors
// ================
// ================
// Destructor ~Cube
// ================
Box::~Box(void){
} // Destructor
// ===============
// ==============
// End Destructor
// ==============
// =================
// Member-Functions
// =================
// =======================
double Box::GetEdge(){
return edgeLength;
} // Functon Get EdgeLength
// ===========================
// ======================
// Mutator Function Set()
// ===========================
void Box::Set(double x){
edgeLength = x;
}// Mutator Function Set
// ========================
// ======================
// Member-Function Output
// ============================
void Box::OutputSurface(){
cout << edgeLength << endl;
cout << endl;
} // Member Function Output
// ===========================
// ==============================
// Member-Function Surface (cube)
// ==============================
void Box::Surface(Box A){
edgeLength = 2 * (boxWidth + boxLength + boxHeight);
} // Function Square Area
// =======================
// =============================
// Member Function Volume (Cube)
// =============================
void Box::Volume(Box X){
edgeLength = boxWidth* boxLength* boxHeight;
}// Function Circle Area
// ========================
// ====================
// End Member Functions
// ====================
MenuClass.cpp
// MenuClass.cpp
#include "stdafx.h"
#include <iostream>
#include "MenuClass.h"
using namespace std;
// ============
// Constructors
// ============
// ===================
// Default Constructor
// ===========================
MenuClass::MenuClass(void){
userMenuSelection = Quit;
} // Constructor Menu
// =======================
// ================
// End Constructors
// ================
// ==========
// Destructor
// ================================
MenuClass::~MenuClass(void){
// cout << "Destructor ~Menu invoked." << endl;
}// Destructor ~Menu
// ====================
/// ==============
// End Destructor
// ==============
// ================
// Member-Functions
// ================
// ==============================
// Accessor Member-Function Get()
// ==============================
MenuChoices MenuClass::Get(){
return userMenuSelection;
} // Accessor Method Get
// =========================
// =============================
// Mutator Member-Function Set()
// ===================================
void MenuClass::Set(MenuChoices newValue){
userMenuSelection = newValue;
} // Mutator Method Set
// ========================
// =========================
// Member-Function Display()
// =========================
void MenuClass::Display(){
cout << endl;
cout << "**************************************************************" << endl;
cout << "* 1: Enter Length 2: Output Surface Area *" << endl;
cout << "* 3: Output Volume 4: Quit *" << endl;
cout << "**************************************************************" << endl;
}// Member-Function Display
// ===========================
// =========================
// Member-Function QueryUser
// ============================
void MenuClass::QueryUser(){
int selection;
cout << "Enter Menu Selection: ";
cin >> selection;
switch (selection){
case 1: userMenuSelection = GetEdge;
break;
case 2: userMenuSelection = OutputSurface;
break;
case 3: userMenuSelection = OutputVolume;
break;
case 4: userMenuSelection = Quit;
break;
default: userMenuSelection = Quit;
break;
cout << endl;
}
} // Method QueryUser()
// =======================
// ===============
// Method Continue
// ===========================
bool MenuClass::ContinueA() {
return userMenuSelection != Quit;
} // Method continue
// ====================
// ==============================
// Member-Function ProcessCommand
// ==================================
void MenuClass::ProcessCommand(){
int numA;
Box numberA;
double orginalNum;
if (userMenuSelection != Quit){
// =====
// Input
// ===========================================
cout << endl << "Enter an integer value: ";
cin >> numA;
numberA.Set(numA);
// Input
// ==========
// ============================
switch (userMenuSelection) {
case GetEdge:
orginalNum = numberA.GetEdge();
cout << orginalNum;
break;
case OutputSurface:
orginalNum = numberA.GetEdge();
cout << "Your surface area is: "
<< orginalNum
<< endl;
break;
case OutputVolume:
orginalNum = numberA.GetEdge();
cout << "Your volume is: " << orginalNum << endl;
break;
case Quit:
break;
default: cout << "Warning: error state encountered." << endl;
} // Switch
// ===========
cout << endl;
} // then
} // Method ProcessCommand()
// ============================
// ====================
// End Member-Functions
// ====================
Box.h
#pragma once
#include "stdafx.h"
class Box {
public:
// ============
// Constructors
// ============
Box(void);
Box(double);
// =============
~Box();
// =========
// Functions
// ======================
double Box::GetEdge();
void Box::Set(double);
void Box::OutputSurface();
void Box::OutputVolume();
void Box::Surface(Box);
void Box::Volume(Box);
// ==========================
// ========================
// Private Member Functions
// ========================
private:
double edgeLength;
double boxHeight;
double boxWidth;
double boxLength;
}; // Class Cube
// =================
MenuClass.h
// MenuClass.h
#pragma once
// ================
// enumerated types
// ================================================================
enum MenuChoices { GetEdge, OutputSurface, OutputVolume, Quit };
// ================================================================
// ===============
// File Inclusions
// =================
#include <string>
// =================
// ====================
using namespace std;
// ====================
// ===================
class MenuClass {
public:
// ============
// Constructors
// ================
MenuClass(void);
// ================
// ==========
// Destructor
// =================
~MenuClass(void);
// =================
// ==========================
// Member-Function Prototypes
// ==========================
MenuChoices MenuClass::Get(); // Accessor
void MenuClass::Set(MenuChoices); // Mutator
void MenuClass::Display();
void MenuClass::QueryUser();
bool MenuClass::ContinueA();
void MenuClass::ProcessCommand();
// ================================================
private:
// ================
// Member-Variables
// ==============================
MenuChoices userMenuSelection;
// ==============================
}; // Class MenuClass
// =====================