-
Notifications
You must be signed in to change notification settings - Fork 0
/
VehicleCollection.cs
41 lines (35 loc) · 1.2 KB
/
VehicleCollection.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TermProject {
class VehicleCollection : Persistable {
protected List<Vehicle> vehicles;
public VehicleCollection()
: base() // call parent default constructor
{
connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
@"Data source= C:\Users\Lisa\Documents" +
@"\BicycleRental.accdb";
vehicles = new List<Vehicle>();
}
public void PopulateWithGoodAndAvailableBikes() {
string queryString = "SELECT ID FROM Vehicle WHERE PhysicalCondition = 'Good' AND Status = 'Active'";
List<Object> bikeIds = getValues(queryString);
foreach (Object element in bikeIds) {
Vehicle v = new Vehicle();
v.Populate((int)((object[])element)[0]);
vehicles.Add(v);
}
}
public List<Vehicle> GetBikeList() {
return vehicles;
}
public void PrintAll() {
foreach(Vehicle vehicle in vehicles){
vehicle.Print();
}
}
}
}