Newb needing help

I have an assignment due tomorrow and its been a pain. I have no idea where to really start, or even what some of what the professor is asking we didn't go over it in class we where instructed to look it up but I haven't had any luck I'm still working on it and still not complete. Any help would be awesome I'm going to just post here the assignment so you all can read it as I do. A point in the right direction or just help with the code itself would work out great.

Declare the enum
enum unit {metric, English}

The Height class contains the following private data members.
string name;
unit measuretype;
float h; // height in measuretype units (ft. or cm.)

The operations include
// constructor: parameters name, height, measurement type
Height(string nm, float ht, unit m);
PrintHeight(void); // prints height in appropriate unit
// input name, measurement type, and height
ReadHeight(void);
float GetHeight(void); // return height
void Convert(unit m); // converts h to measurement m

(a) Implement the class. There are 2.54 centimeters per inch
(b) Write a function that scans a list and converts all the items to a unit of measurement that is given as a parameter. Assume that objects are expressed in the other unit of measurement. The five objects are: shoe, nightstand, flat screen tv, window and door frame. To make the scan quicker, create an array of 5 objects.
(c) Write a function that shorts an array of Heights objects. It is assumed that each object uses the same unit of measurement.
(d) Write a function that scans an array and returns an object representing the longest object. Assume all object use the same unit of measurement.
(e) Write a program to test the class by creating a list of five items of type Height. Initialize the first three in the declaration and read the last two. Use the function developed in parts (b), (c) and (d).

Hmm, well it seems to be that the Height class is really an Object class. This class will just hold the name of the object, height of the object and measure type, and a few functions. After you make this class, just create 5 objects of it (shoe, nightstand, tv, window, and door frame). I don't really see where the problem you're have is.
So what's exactly your question? I think it's quite straight forward as how to proceed. If on the other hand you get stuck then ask.

Have you done something so far?
Sorry I was not even awake at the times you two replied haha, well I do have some so far working on the class however it probably is straight forward to you guys but its going over something we did not cover in class. Mostly the enum is something I've never seen until this assignment I know about classes however.
Well I am a newbie as well, but I wrote a quick example of what I understand enumerators to be.
Compile if you wish :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;

void example2();

int main(void)
{
	/*the first identifier represents the value 0 if none is specified.
	//each subsequent identifier is increased by 1 until the end of the list.*/
	enum WeekdaysOfTheWeek{Monday,Tuesday,Wednesday,Thursday,Friday};
	cout << Monday << endl;		//0
	cout << Tuesday << endl;	//1
	cout << Wednesday << endl;	//2
	cout << Thursday << endl;	//3
	cout << Friday << endl;		//4
	cout << "----------------------------\n";
	example2();
	return 0;
}

void example2()
{
	/*you can set a value anywhere for each identifier and the one after
	it will still increase by 1.*/
	enum WeekdaysOfTheWeek{Monday,Tuesday,Wednesday=7,Thursday,Friday=10};
	cout << Monday << endl;		//0
	cout << Tuesday << endl;	//1
	cout << Wednesday << endl;	//7
	cout << Thursday << endl;	//8
	cout << Friday << endl;		//10
	return;
}
Last edited on
Enums are really just a way to get around the whole "magic number" problem. Enums are just a variable where you declare what it can be.
http://www.cprogramming.com/tutorial/enum.html
Thats a good link describing enums. Now with working on the class itself, I dont really see where you're having issues at. If you could put up what you've attempted, we could better assist you.

Biscuit
Topic archived. No new replies allowed.