Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class storage
- {
- protected List<tablet> list = new List<tablet>();
- public void Add(tablet a)
- {
- if (a == null) throw new Exception("null nem lehet");
- list.Add(a);
- }
- public void Delete(tablet a)
- {
- int i = list.IndexOf(a);
- if (i == -1) throw new Exception("nincs a listan");
- list.RemoveAt(i);
- }
- public void Delete(int i)
- {
- if (i<0) throw new Exception("nincs ilyen index");
- if (i >= list.Count ) throw new Exception("nincs ilyen index");
- list.RemoveAt(i);
- }
- public int dbszam
- {
- get { return list.Count; }
- }
- public int total_cost
- {
- get
- {
- int sum = 0;
- foreach (tablet t in list)
- sum = sum + t.cost;
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment