C++ class diagram for a code?

What are the attributes and the methods of this code here? I think the attributes are romantype,romannumeral, Kind of thought those were also the methods... but I don't know. Does anybody know?

#include <iostream>

using namespace std;

class romanType{

public:

romanType(char&); // ** make constructor

int convert();

void print();

void get();

private:

int M, D, C, L, X, V, I;

char romanNumeral;

};

romanType::romanType(char &ch){

M = 1000;

D = 500;

C = 100;

L = 50;

X = 10;

V = 5;

I = 1;

cout << ch << endl;

romanNumeral=ch; // ** set up romanNumeral

}

int romanType::convert(){

if (romanNumeral == 'M'){

return 1000; // ** return value

}else if(romanNumeral == 'D'){

return 500;

}else if(romanNumeral == 'C'){

return 100;

}else if(romanNumeral == 'L'){

return 50;

}else if(romanNumeral == 'X'){

return 10;

}else if(romanNumeral == 'V'){

return 5;

}else if(romanNumeral == 'I'){

return 1;

}

return 0; // ** error -

}

void romanType::print(){

cout << romanNumeral << endl;

}

void romanType::get(){

}

int main(){

char romanNumeral;

cout << "Welcome to the Roman numeral to decimal converter!\nPlease enter a number in Roman numerals to be converted: ";

cin >> romanNumeral;

romanType roman=romanType(romanNumeral); // ** set up value

cout << roman.convert() << endl;;

system("pause");

return 0;

}

Update:

That still dosen't help me. That would be RomanType and RomanNumeral for attributes... and what's the method?

Comments

  • methods = member functions = convert(), print() and get()

    Basically, these are any functions defined in the class that are NOT static.

    attributes = member variables = M, D, C, L, X, V, I and romanNumeral

    Basically, any data variables declared in the class that are NOT static.

    - - - -

    Not part of the question, but variables and functions declared as static in the class definition don't belong to any object...they belong to the class as a whole. Static variables are sometimes called "class attributes" or "class variables", and static functions are often called "class methods". So, when you see them, "class attribute" is NOT the same as an "attribute" and "class member" is NOT another name for "member".

  • The attributes of a class are its data members.

    The methods of a class are its member functions.

Sign In or Register to comment.