-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1603-Design-parking-system.cs
More file actions
78 lines (72 loc) · 2.23 KB
/
1603-Design-parking-system.cs
File metadata and controls
78 lines (72 loc) · 2.23 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Text;
namespace Solution._1603.Design_parking_system
{
public class _1603_Design_parking_system
{
/**
* Your ParkingSystem object will be instantiated and called as such:
* ParkingSystem obj = new ParkingSystem(big, medium, small);
* bool param_1 = obj.AddCar(carType);
*/
public class ParkingSystem
{
private int[] _arr;
public ParkingSystem(int big, int medium, int small)
{
_arr = new int[3] { big, medium, small };
}
public bool AddCar(int carType)
{
if (_arr[carType - 1] > 0)
{
_arr[carType - 1] -= 1;
return true;
}
return false;
}
//private int _big;
//private int _medium;
//private int _small;
//public ParkingSystem(int big, int medium, int small)
//{
// _big = big;
// _medium = medium;
// _small = small;
//}
//public bool AddCar(int carType)
//{
// switch (carType)
// {
// case 1:
// if (_big > 0)
// {
// _big--;
// return true;
// }
// else return false;
// break;
// case 2:
// if (_medium > 0)
// {
// _medium--;
// return true;
// }
// else return false;
// break;
// case 3:
// if (_small > 0)
// {
// _small--;
// return true;
// }
// else return false;
// break;
// default:
// return false;
// }
//}
}
}
}