-
Notifications
You must be signed in to change notification settings - Fork 1
/
Seller.cs
68 lines (59 loc) · 1.74 KB
/
Seller.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace task_2
{
internal class Seller: User
{
protected Product[] products;
private int size = 2;
private int productLogicSize = 0;
public Seller(string name, string password, Address address) :base(name, password, address)
{
this.name = name;
this.password = password;
this.address = address;
products = new Product[size];
}
public Seller(User others):base(others)
{
products = new Product[size];
}
public Product GetProduct(string productName)
{
foreach (Product product in products)
{
if(product.GetProductName() == productName)
return product;
}
return null;
}
public bool SetProduct(Product productDetails)
{
Product[] tempNewProducts;
if (productLogicSize == products.Length)
{
tempNewProducts = new Product[products.Length * size];
products.CopyTo(tempNewProducts, 0);
products = tempNewProducts;
}
products[productLogicSize] = productDetails;
productLogicSize++;
return true;
}
public string ToString()
{
string res = "";
foreach (var productDetail in products)
{
if (productDetail != null)
res += GetBuyerName() + productDetail.ToString();
else
break;
}
return res;
}
}
}