-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingredient.cpp
More file actions
41 lines (33 loc) · 748 Bytes
/
ingredient.cpp
File metadata and controls
41 lines (33 loc) · 748 Bytes
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
// ingredient.cpp
#include <stdlib.h>
#include <iostream>
#include <string>
#include "ingredient.h"
Ingredient::Ingredient() : m_name("bad"), m_cost(0) {}
Ingredient::Ingredient(std::string name, double cost)
: m_name(name), m_cost(cost) {}
Ingredient::Ingredient(const Ingredient& other)
{
m_name = other.getName();
m_cost = other.getCost();
}
Ingredient& Ingredient::operator=(const Ingredient& other)
{
if (this == &other)
return *this;
m_name = other.getName();
m_cost = other.getCost();
}
std::string Ingredient::getName() const
{
return m_name;
}
double Ingredient::getCost() const
{
return m_cost;
}
std::ostream& operator<< (std::ostream& os, const Ingredient& ingred)
{
os << ingred.getName();
return os;
}