-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
62 lines (52 loc) · 1.45 KB
/
Client.java
File metadata and controls
62 lines (52 loc) · 1.45 KB
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
package model;
import java.util.HashMap;
import model.IClient;
import model.Portfolio;
/**
* The model.Client class represents a client who can manage multiple portfolios.
* Each client has a name and a collection of portfolios.
*/
public class Client implements IClient {
protected String name;
protected HashMap<String, SmartPortfolio> portfolios;
/**
* Constructs a new model.Client with the specified name.
*
* @param name the name of the client
*/
public Client(String name) {
this.name = name;
this.portfolios = new HashMap<>();
}
/**
* Returns the collection of portfolios managed by this client.
*
* @return a HashMap containing the client's portfolios, where the keys are portfolio names
* and the values are model.Portfolio objects
*/
@Override
public HashMap<String, SmartPortfolio> getPortfolios() {
return portfolios;
}
/**
* Creates a new portfolio with the specified name and adds it to the client's collection
* of portfolios.
*
* @param portfolioName the name of the new portfolio
* @return the newly created model.Portfolio object
*/
@Override
public Portfolio createPortfolio(String portfolioName) {
SmartPortfolio newPortfolio = new SmartPortfolio(portfolioName, this);
portfolios.put(portfolioName, newPortfolio);
return newPortfolio;
}
/**
* Getter method for name.
*
* @return name
*/
public String getName() {
return name;
}
}