-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathSmartPhone.cpp
105 lines (82 loc) · 2.34 KB
/
SmartPhone.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "SmartPhone.h"
#include <iostream>
using std::cout;
int SmartPhone::numPhones = 0;
const Data SmartPhone::RELEASEDATE = Data( 25, 9, 2021 );
SmartPhone::SmartPhone( )
:pinCode(0), IDPHONE( 12345 ), dataAtual( )
{
numPhones++;
}
SmartPhone::SmartPhone( int IDPh, const Data &dataOut )
:IDPHONE(IDPh), dataAtual(dataOut)
{
numPhones++;
}
SmartPhone::SmartPhone( const SmartPhone &sp )
:pinCode(sp.pinCode), IDPHONE(sp.IDPHONE), dataAtual(sp.dataAtual)
{
history = sp.history;
numPhones++;
//Update contact list
contacts.resize( sp.contacts.size( ) );
for( int i = 0; i < contacts.size( ); i++ )
contacts[ i ] = new Pessoa( *sp.contacts[ i ] );//deferenciar o ponteiro. Contacts é um vector de Pessoas
}
SmartPhone::~SmartPhone( )
{
for( int i = 0; i < contacts.size( ); i++ )
delete contacts[ i ];
}
void SmartPhone::mostrarInfo( )
{
cout << "A data de lancamento deste modelo eh: ";
RELEASEDATE.print( );
cout << '\n';
cout << "O numero de smartphones vendidos eh: " << numPhones << '\n';
}
void SmartPhone::updateHistory(const string &newPage)
{
history.push_back( newPage );
}
void SmartPhone::listHistory( ) const
{
cout << "As paginas visitas foram\n";
for( unsigned int i = 0; i < history.size( ); i++ )
cout << history[ i ] << '\n';
}
void SmartPhone::mostrarData( ) const
{
cout << "A data atual eh: "; dataAtual.print( );
cout << '\n';
}
void SmartPhone::printContactList( ) const
{
cout << "Minha lista de contatos eh:\n\n";
for( int i = 0; i < contacts.size( ); i++ )
cout << *contacts[ i ] << '\n';
}
void SmartPhone::addContact( const Pessoa &newcontact )
{
contacts.push_back( new Pessoa( newcontact ) );
}
void SmartPhone::addContact( const string &name, const string &phoneNumber, const vector< string > &socialMediaConection )
{
contacts.push_back( new Pessoa( name, phoneNumber, socialMediaConection ) );
}
void SmartPhone::deleteLastContact( )
{
delete contacts[ contacts.size() - 1 ];
contacts.pop_back( );
}
ostream &operator<<( ostream &out, const SmartPhone &smarty )
{
out << "A data de lancamento deste modelo eh: ";
smarty.RELEASEDATE.print( );
out << '\n';
out << "O numero de smartphones vendidos eh: " << smarty.numPhones << '\n';
out << "Minha lista de contatos eh:\n\n";
for( int i = 0; i < smarty.contacts.size( ); i++ )
out << *smarty.contacts[ i ] << '\n';
return out;
}