Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- using namespace std;
- class Seller
- {
- public:
- Seller();
- Seller( const char [], const char[], const char [], double );
- void print();
- void setFirstName( const char [] );
- void setLastName( const char [] );
- void setID( const char [] );
- void setSalesTotal( double );
- double getSalesTotal();
- private:
- char firstName[20];
- char lastName[30];
- char ID[7];
- double SalesTotal;
- };
- int main()
- {
- Seller first = Seller("Luke","Schwaller","CSCI240",1234.56);
- Seller second = Seller();
- Seller third = Seller("","Johnson","TOOBIG999",876.34);
- Seller fourth = Seller("James","Hellwig","ULTWAR",13579.11);
- Seller fifth = Seller("Roderick","Toombs","PIPER4",24680.24);
- cout<<" **** The first Seller object ****"<<endl<<endl;
- first.print();
- cout<<"\n\n**** The second Seller object ****"<<endl<<endl;
- second.print();
- second.setFirstName("Terry") ;
- second.setLastName("Bollea");
- second.setID("HULK96");
- second.setSalesTotal(246.80);
- second.print();
- cout<<"\n\n*** The third Seller object ***"<<endl<<endl;
- third.print();
- third.setFirstName("Dwayne");
- third.setID("ROCK89");
- third.print();
- cout<<"\n\n*** The fourth Seller object ***"<<endl<<endl;
- fourth.print();
- cout<<"\n\n*** The fifth Seller object ***"<<endl<<endl;
- fifth.print();
- fifth.setFirstName("");
- fifth.setLastName("");
- fifth.setID("");
- fifth.setSalesTotal(-19.88);
- }
- void Seller::print()
- {
- cout<<firstName[1]<<", "<<lastName[1]<<setw(15)<<ID[1]<<SalesTotal;
- }
- void Seller::setFirstName(const char newFirstName[])
- {
- if( strlen(newFirstName) > 0 )
- {
- strcpy(firstName, newFirstName);
- }
- else
- {
- strcpy( firstName, "None");
- }
- }
- void Seller::setLastName(const char newLastName[])
- {
- if( strlen(newLastName) > 0 )
- {
- strcpy(lastName, newLastName);
- }
- else
- {
- strcpy( lastName, "None");
- }
- }
- void Seller::setID(const char newID[])
- {
- if( strlen(newID) > 0 )
- {
- if (strlen(newID)< 7)
- {
- strcpy(ID, newID);
- }
- }
- else
- {
- strcpy( ID, "None");
- }
- }
- void Seller::setSalesTotal(double newSalesTotal)
- {
- if(newSalesTotal < 0)
- {
- SalesTotal = newSalesTotal;
- }
- else
- {
- SalesTotal = 0;
- }
- }
- double Seller::getSalesTotal()
- {
- return SalesTotal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement