// ----------------------------------------------------------------------------------------------------------------- // STATIC public static apple Instantiate(apple.CConfig cfg) { apple obj = cfg.mesh.Instantiate("apple").AddComponent <apple>(); obj.m_config = cfg; return(obj); }
void OnTriggerEnter(Collider col) { Debug.Log("collided with " + col); if (col.gameObject.tag == "pickup") { apple a = col.gameObject.GetComponent <apple>(); a.Pickup(this); } }
static void FruitSample() { apple myApple = new apple(); myApple.EatFruit(); fruit myFruit = new apple(); myFruit.EatFruit(); Orange myOrange = new Orange(); myOrange.EatFruit(); RanchStyle ranch = new RanchStyle("Stone", "Triple Pane", "Composite", "Blue"); ranch.OpenDoor(); Console.WriteLine(ranch.Roof); }
public ResultModel CreateBatch(apple model) { var result = new ResultModel(); var _conn = new GetConnection(_config); using (var conn = new SqlConnection(new GetConnection(_config).applePenConnection())) { //INSERT DATA var sql = @"INSERT INTO apples(name) VALUES (@name); "; var pList = new List <DynamicParameters>();//多筆資料 for (int i = 0; i < 10000; i++) { var p = new DynamicParameters(); p.Add("@name", model.name, DbType.String, direction: ParameterDirection.Input); p.Add("@r", DbType.Int32, direction: ParameterDirection.ReturnValue); pList.Add(p); } var sw = new Stopwatch(); sw.Start(); try { conn.Execute(sql, pList); //var rr = conn.Execute("sp_create_apple", pList, commandType: CommandType.StoredProcedure); //result.d = p.Get<dynamic>("@r");//接收SP回傳值 } catch (Exception e) { result.r = false; result.d = e; return(result); } //GET latest data sql = @"SELECT TOP(1) * FROM apples ORDER BY id DESC"; var query = conn.Query(sql).SingleOrDefault(); sw.Stop(); result.r = true; result.m = "Elapsed time = " + sw.ElapsedMilliseconds / 1000.0 + "s"; //result.d = query; } return(result); }
void Start() { // 1. 声明一个水果类,具有如下成员:颜色,名称,重量。 // 2. 声明一个苹果类继承自水果类,实例化一个1斤重的红色苹果。 red_apple = new apple(); red_apple.name = "red apple"; red_apple.color = "red"; red_apple.weight = 1.0f; //3. 随机实例化10个0.1到1.5斤重的红色苹果,求出这些苹果的总重量。 furit[] red_apples00 = new furit[10]; float n = 0f; for (int i = 0; i < red_apples00.Length; ++i) { red_apples00[i] = new apple(); red_apples00[i].name = "red apple"; red_apples00[i].color = "red"; red_apples00[i].weight = Random.Range(0.1f, 1.5f); n += red_apples00[i].weight; } Debug.Log("这些苹果的总重量:" + n); //4. 已知绿色苹果8元/斤,红色苹果12元/斤,实例化5个0.5到1.8斤重的绿苹果,实例化6个0.2到1.2斤重的红苹果。求这些苹果的总价钱。 furit[] red_apples01 = new furit[6]; float n1 = 0f; for (int i = 0; i < red_apples01.Length; ++i) { red_apples01[i] = new apple(); red_apples01[i].name = "red apple"; red_apples01[i].color = "red"; red_apples01[i].weight = Random.Range(0.2f, 1.2f); n1 += red_apples01[i].weight; } //Debug.Log(n1); furit[] green_apples01 = new furit[5]; float n2 = 0f; for (int i = 0; i < green_apples01.Length; ++i) { green_apples01[i] = new apple(); green_apples01[i].name = "green apple"; green_apples01[i].color = "green"; green_apples01[i].weight = Random.Range(0.5f, 1.8f); n2 += green_apples01[i].weight; } //Debug.Log(n2); float money = 0f; money = n1 * 12f + n2 * 8f; Debug.Log("这些苹果的总价钱:" + money); //5. 白白喜欢吃的水果有苹果,桔子。巫巫喜欢吃的水果有苹果,西瓜。淡淡喜欢吃的水果有樱桃,哈密瓜。小猴子最喜欢吃的水果有香蕉。请声明数组存储三个人类和一只猴子。 furit[] furits = new furit[6]; furits[0] = new apple(); furits[0].name = "apple"; furits[0].color = "red color"; furits[1] = new oringe(); furits[1].name = "oringe"; furits[1].color = "oringe color"; furits[2] = new watermelon(); furits[2].name = "watermelon"; furits[2].color = "green color"; furits[3] = new melon(); furits[3].name = "melon"; furits[3].color = "green color"; furits[4] = new cherry(); furits[4].name = "cherry"; furits[4].color = "pink color"; furits[5] = new banana(); furits[5].name = "banana"; furits[5].color = "yellow color"; life[] lifes = new life[4]; lifes[0] = new baibai(); lifes[0].name = "baibai"; lifes[0].favourite01 = furits[0]; lifes[0].favourite02 = furits[1]; lifes[1] = new wuwu(); lifes[1].name = "wuwu"; lifes[1].favourite01 = furits[0]; lifes[1].favourite02 = furits[2]; lifes[2] = new dandan(); lifes[2].name = "dandan"; lifes[2].favourite01 = furits[3]; lifes[2].favourite02 = furits[4]; lifes[3] = new monkey(); lifes[3].name = "monkey"; lifes[3].favourite01 = furits[5]; lifes[3].favourite02 = furits[5]; // 6. 遍历数组,打印出白白喜欢吃的水果的名称和颜色。 // 7. 遍历数组,打印数组里非人类喜欢吃的水果的名称和颜色。 for (int i = 0; i < lifes.Length; ++i) { if (lifes[i].name == "baibai") { Debug.Log("白白喜欢吃的水果的名称:" + lifes[i].favourite01.name + "和" + lifes[i].favourite02.name); Debug.Log("白白喜欢吃的水果的颜色:" + lifes[i].favourite01.color + "和" + lifes[i].favourite02.color); } if (lifes[i] is human == false) { Debug.Log("非人类喜欢吃的水果的名称:" + lifes[i].favourite01.name + "和" + lifes[i].favourite02.name); Debug.Log("非人类喜欢吃的水果的颜色:" + lifes[i].favourite01.color + "和" + lifes[i].favourite02.color); } } //8. 已知白白最好的朋友是巫巫,巫巫最好的朋友是淡淡,淡淡最好的朋友是小猴子,小猴子最好的朋友是白白,打印出白白的好朋友的好朋友的好朋友喜欢吃的水果的名称和颜色。 lifes[0].friend = lifes[1]; lifes[1].friend = lifes[2]; lifes[2].friend = lifes[3]; lifes[3].friend = lifes[0]; Debug.Log("白白的好朋友的好朋友的好朋友喜欢吃的水果的名称是:" + lifes[0].friend.friend.friend.favourite01.name + "和" + lifes[0].friend.friend.friend.favourite02.name); Debug.Log("白白的好朋友的好朋友的好朋友喜欢吃的水果的颜色是:" + lifes[0].friend.friend.friend.favourite01.color + "和" + lifes[0].friend.friend.friend.favourite02.color); }
void Awake() { lr = GetComponent <LineRenderer>(); stop = GetComponent <apple>(); }