Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace firstC____prog
- {
- class product
- {
- public product(string str)
- {
- var arr = str.Split(' ');
- var nType = int.Parse(arr[0]);
- switch(nType)
- {
- case 1:
- type = Type.phone;
- break;
- case 2:
- type = Type.tv;
- break;
- case 3:
- type = Type.clock;
- break;
- }
- mark = arr[1];
- cost = int.Parse(arr[2]);
- warranty = byte.Parse(arr[3]);
- this.ObjectID = Guid.NewGuid();
- this.SaleTime = DateTime.Now;
- }
- public Type type
- {
- get;
- set;
- }
- public string mark
- {
- get;
- set;
- }
- public int cost
- {
- get;
- set;
- }
- public byte warranty
- {
- get;
- set;
- }
- public Guid ObjectID
- {
- get;
- set;
- }
- public DateTime SaleTime
- {
- get;
- set;
- }
- }
- enum Type
- {
- phone,
- tv,
- clock
- }
- }
- public bool HasProductThisTipe(product[] arr, Type type, out int count )
- {
- int i=0;
- foreach(var a in arr)
- {
- if (a.type == type) i++;
- }
- count = i;
- return count != 0 ? true : false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement