The purpose of this project is to familiarize the student wi
The purpose of this project is to familiarize the student with defining classes from a Uniform Modeling Language (UML) Class Diagram. In prior assignments we saw how structure charts could be used to design a modular program using the top-down design methodology and how flowcharts could be used to depict the detail logic of a specific module. To design an object-oriented program, we can also use symbolic notation. There are a few modeling languages to choose from, but UML has quickly become a de-facto standard.
The only thing required for this assignment is the class definition and an empty main function which is required by the compiler. The class definition created here will then be used to complete P12 SalesPerson Implementation.
UML - Class Diagram:
Symbol definitions:
- private
+ public
# protected
| C++ Level I P11 SalesPerson Class Interface - 10 points (submit source code) |
Solution
Code:
#include <string> // string class
#include<iostream>
using namespace std;
//Class definition - the interface for the class
class SalesPerson
{
private:
int salesPersonId;
string firstName;
string lastName;
public:
SalesPerson(){
salesPersonId=0;
firstName=\"\";
lastName=\"\";
}
SalesPerson(int id,string first,string last){
salesPersonId=id;
firstName=first;
lastName=last;
}
~SalesPerson(){
}
void setSalesPersonId(int id){
salesPersonId=id;
}
void setFirstName(string fn){
firstName=fn;
}
void setLastName(string ln){
lastName=ln;
}
int getSalesPersonId(){
return salesPersonId;
}
string getFirstName(){
return firstName;
}
string getLastName(){
return lastName;
}
void inputSalesPersonId(){
cout<<\"Enter id:\";
cin>>salesPersonId;
}
void inputFirstName(){
cout << \"Enter your first name: \";
getline(cin, firstName);
}
void inputLastName(){
cout << \"Enter your last name: \";
getline(cin, lastName);
}
};
//Need empty main so program will compile
int main()
{
return 0;
}

