static void Main(string[] args) { dog Dog = new dog(); cat Cat = new cat(); string A = Console.ReadLine(); if (A == "dog") { Dog.sound(); } else if (A == "cat") { Cat.sound(); } }
private void Bt1_Click(object sender, RoutedEventArgs e) { itsName = Input.Text; if (itsName == "cat") { c = new cat(words); //注册事件 Say += new AnimalSaying(c.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(c.saying);//注销事件*/ } else if (itsName == "dog") { d = new dog(words); //注册事件 Say += new AnimalSaying(d.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(d.saying);//注销事件*/ } else if (itsName == "pig") { p = new pig(words); //注册事件 Say += new AnimalSaying(p.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(p.saying);//注销事件*/ } Input.Text = ""; }
private void Button_Click_(object sender, RoutedEventArgs e) { c = new cat(words); d = new dog(words); p = new pig(words); if (textBox.Text == "cat" || textBox.Text == "Cat") { Say += c.saying; Say(this, new myEventArgs(times++)); Say -= c.saying; } else if (textBox.Text == "dog" || textBox.Text == "Dog") { Say += d.saying; Say(this, new myEventArgs(times++)); Say -= d.saying; } else if (textBox.Text == "pig" || textBox.Text == "Pig") { Say += p.saying; Say(this, new myEventArgs(times++)); Say -= p.saying; } else { } textBox.Text = ""; }
private void SpeSay_Click(object sender, RoutedEventArgs e) { if (t1 == 0) { c = new cat(words); d = new dog(words); p = new pig(words); } string s = ani.Text; if (s != "") { if (s == "cat") { SpeSay = new AnimalSaying(c.saying); SpeSay(this, new myEventArgs(t1++)); SpeSay -= new AnimalSaying(c.saying); } else if (s == "dog") { SpeSay = new AnimalSaying(d.saying); SpeSay(this, new myEventArgs(t1++)); SpeSay -= new AnimalSaying(d.saying); } else if (s == "pig") { SpeSay = new AnimalSaying(p.saying); SpeSay(this, new myEventArgs(t1++)); SpeSay -= new AnimalSaying(p.saying); } ani.Text = ""; } }
private void RanSay_Click(object sender, RoutedEventArgs e) { if (t2 == 0) { c = new cat(words); d = new dog(words); p = new pig(words); } int n = rdm.Next(3); switch(n) { case 0: RanSay = new AnimalSaying(c.saying); break; case 1: RanSay = new AnimalSaying(d.saying); break; case 2: RanSay = new AnimalSaying(p.saying); break; } RanSay(this, new myEventArgs(t2++)); }
private void Bt2_Click_1(object sender, RoutedEventArgs e) { Random ran = new Random(); int RandKey = ran.Next(1, 4); if (RandKey == 1) { c = new cat(words); //注册事件 Say += new AnimalSaying(c.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(c.saying);//注销事件*/ } else if (RandKey == 2) { d = new dog(words); //注册事件 Say += new AnimalSaying(d.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(d.saying);//注销事件*/ } else if (RandKey == 3) { itsName = "pig"; p = new pig(words); //注册事件 Say += new AnimalSaying(p.saying); //执行事件 Say(this, new myEventArgs(itsName));//事件中传递参数itsName Say -= new AnimalSaying(p.saying);//注销事件*/ } }
private void Button_Click(object sender, RoutedEventArgs e) { words.Text = ""; //C#事件的绑定机制决定了必须每次清空 if (c == null) { c = new cat(words); d = new dog(words); p = new pig(words); } Random rd = new Random(); //产生随机数 int flag = rd.Next(); if (flag % 3 == 0) //用取模的结果限定随机输出 { Say += new AnimalSaying(c.saying); } else if (flag % 3 == 1) { Say += new AnimalSaying(d.saying); } else { Say += new AnimalSaying(p.saying); } //执行事件 Say(this, EventArgs.Empty); }
private void speak_btn_Click(object sender, RoutedEventArgs e) { Random ran = new Random(); int n = ran.Next(0, 3); textBlock.Text = ""; if (n == 0) { p = new pig(textBlock); Speak += new animal_speak(p.saying); } else if (n == 1) { d = new dog(textBlock); Speak += new animal_speak(d.saying); } else { c = new cat(textBlock); Speak += new animal_speak(c.saying); } Speak(this, new EventArgs()); switch (n) { case 0: Speak -= new animal_speak(p.saying); break; case 1: Speak -= new animal_speak(d.saying); break; case 2: Speak -= new animal_speak(c.saying); break; } }
private void ok_Click(object sender, RoutedEventArgs e) { if (word_in.Text == "dog") { word_out.Text = ""; d = new dog(word_out); Say += new AnimalSaying(d.saying); Say(this, new myEventArgs(times++)); //事件中传递参数times } else if (word_in.Text == "cat") { word_out.Text = ""; c = new cat(word_out); Say += new AnimalSaying(c.saying); Say(this, new myEventArgs(times++)); //事件中传递参数times } else if (word_in.Text == "pig") { word_out.Text = ""; p = new pig(word_out); Say += new AnimalSaying(p.saying); Say(this, new myEventArgs(times++)); //事件中传递参数times } word_in.Text = ""; }
private void speakButton_Click(object sender, RoutedEventArgs e) { words.Text = ""; c = new cat(words); d = new dog(words); p = new pig(words); //获取随机数 Random r = new Random(); int RandKey = r.Next(0, 30); //根据随机数来注销事件和注册事件 if (RandKey >= 0 && RandKey < 10) { Say -= new AnimalSaying(d.saying); Say -= new AnimalSaying(p.saying); Say += new AnimalSaying(c.saying); } else if (RandKey >= 10 && RandKey < 20) { Say -= new AnimalSaying(c.saying); Say -= new AnimalSaying(p.saying); Say += new AnimalSaying(d.saying); } else { Say -= new AnimalSaying(c.saying); Say -= new AnimalSaying(d.saying); Say += new AnimalSaying(p.saying); } //执行事件 Say(this, new myEventArgs()); }
public dog(dog i) { name = i.name; color = i.color; age = i.age; birthYear = i.birthYear; }
internal string DognameGetTest([PexAssumeUnderTest] dog target) { string result = target.Dogname; return(result); // TODO: add assertions to method dogTest.DognameGetTest(dog) }
private void OK(object sender, RoutedEventArgs e) { if (input.Text == "cat") { c = new cat(words); words.Text = ""; Say += new AnimalSaying(c.saying); Say(this); } if (input.Text == "dog") { d = new dog(words); words.Text = ""; Say += new AnimalSaying(d.saying); Say(this); } if (input.Text == "pig") { p = new pig(words); words.Text = ""; Say += new AnimalSaying(p.saying); Say(this); } input.Text = ""; }
private void button_Copy_Click(object sender, RoutedEventArgs e) { words.Text = ""; c = new cat(words); d = new dog(words); p = new pig(words); Random rd = new Random(); int num = rd.Next(0, 3); switch (num) { case 0: Say = new AnimalSaying(p.saying); Say(p); break; case 1: Say = new AnimalSaying(d.saying); Say(d); break; case 2: Say = new AnimalSaying(c.saying); Say(c); break; } }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (textBox.Text == "cat") { c = new cat(words); Say += new AnimalSaying(c.saying); Say(this, new myEventArgs(times++)); Say -= new AnimalSaying(c.saying); textBox.Text = ""; } else if (textBox.Text == "dog") { d = new dog(words); Say += new AnimalSaying(d.saying); Say(this, new myEventArgs(times++)); Say -= new AnimalSaying(d.saying); textBox.Text = ""; } else if (textBox.Text == "pig") { p = new pig(words); Say += new AnimalSaying(p.saying); Say(this, new myEventArgs(times++)); Say -= new AnimalSaying(p.saying); textBox.Text = ""; } else { textBox.Text = ""; } }
private void RanSay_Click(object sender, RoutedEventArgs e) { if (t2 == 0) { c = new cat(words); d = new dog(words); p = new pig(words); } int n = rdm.Next(3); if (n == 0) { RanSay += c.saying; RanSay(this, new myEventArgs(t2++)); RanSay -= c.saying; } else if (n == 1) { RanSay += d.saying; RanSay(this, new myEventArgs(t2++)); RanSay -= d.saying; } else if (n == 2) { RanSay += p.saying; RanSay(this, new myEventArgs(t2++)); RanSay -= p.saying; } }
private void SpeSay_Click(object sender, RoutedEventArgs e) { if (t1 == 0) { c = new cat(words); d = new dog(words); p = new pig(words); } string s = ani.Text; if (s != "") { if (s == "cat") { SpeSay += c.saying; SpeSay(this, new myEventArgs(t1++)); SpeSay -= c.saying; } else if (s == "dog") { SpeSay += d.saying; SpeSay(this, new myEventArgs(t1++)); SpeSay -= d.saying; } else if (s == "pig") { SpeSay += p.saying; SpeSay(this, new myEventArgs(t1++)); SpeSay -= p.saying; } ani.Text = ""; } }
private void button_Click(object sender, RoutedEventArgs e) { if (times % 18 == 0) { textBlock.Text = ""; } Random ran = new Random(); int RandomKey = ran.Next(0, 6); if (RandomKey == 0 || RandomKey == 3) { c = new cat(textBlock); Say += new AnimalSaying(c.saying); } else if (RandomKey == 1 || RandomKey == 4) { d = new dog(textBlock); Say += new AnimalSaying(d.saying); } else { p = new pig(textBlock); Say += new AnimalSaying(p.saying); } Say(this, new myEventArgs(times++)); Say = null;; }
private void Button_Click(object sender, RoutedEventArgs e) { this.textBlock.Text = ""; if (times == 0) { c = new cat(this.textBlock); d = new dog(this.textBlock); p = new pig(this.textBlock); } Random i = new Random(); int x = i.Next(3); switch (x) { case 0: Say += new AnimalSaying(c.saying); Say(this, new myEventArgs(times++)); break; case 1: Say += new AnimalSaying(d.saying); Say(this, new myEventArgs(times++)); // Say -= new AnimalSaying(d.saying); break; case 2: Say += new AnimalSaying(p.saying); Say(this, new myEventArgs(times++)); // Say -= new AnimalSaying(p.saying); break; } }
internal dog ConstructorTest(string dogname) { dog target = new dog(dogname); return(target); // TODO: add assertions to method dogTest.ConstructorTest(String) }
private void Button_Click1(object sender, RoutedEventArgs e) { this.textBlock.Text = ""; if (ttimes == 0) { c = new cat(this.textBlock); d = new dog(this.textBlock); p = new pig(this.textBlock); ttimes++; } switch (this.textBox.Text) { case "cat": Say += new AnimalSaying(c.saying); Say(this, new myEventArgs(times++)); // Say -= new AnimalSaying(c.saying); break; case "dog": Say += new AnimalSaying(d.saying); Say(this, new myEventArgs(times++)); // Say -= new AnimalSaying(d.saying); break; case "pig": Say += new AnimalSaying(p.saying); Say(this, new myEventArgs(times++)); // Say -= new AnimalSaying(p.saying); break; default: break; } this.textBox.Text = ""; }
static void Main(string[] args) { try { Horse Bobby = new Horse(152, 12, "four", "Venison"); Bobby.YearsOld(); Bobby.Legs(); Bobby.TypesofMeat(); pigs Tommy = new pigs(76, 4, "five", "Bacon, Porkchops"); Tommy.YearsOld(); Tommy.Legs(); Tommy.TypesofMeat(); Cows Randy = new Cows(200, 5, "three", "Steak"); Randy.YearsOld(); Randy.Legs(); Randy.TypesofMeat(); dog Jacob = new dog(50, 3, "four", "dog meat"); Jacob.YearsOld(); Jacob.Legs(); Jacob.TypesofMeat(); } catch (FormatException Fex) { Console.WriteLine(Fex.Message); Console.ReadKey(); } }
//当用户点击OK按钮对应的操作,实现指定发言 private void Button_ClickofOK(object sender, RoutedEventArgs e) { c = new cat(words); d = new dog(words); p = new pig(words); //对应cat if (name.Text == "cat") { Say += new AnimalSaying(c.saying); //添加事件 Say(this, new myEventArgs(times++)); //执行事件 Say -= new AnimalSaying(c.saying); //删除事件 } //对应dog else if (name.Text == "dog") { Say += new AnimalSaying(d.saying); Say(this, new myEventArgs(times++)); Say -= new AnimalSaying(d.saying); } //对应pig else if (name.Text == "pig") { Say += new AnimalSaying(p.saying); Say(this, new myEventArgs(times++)); Say -= new AnimalSaying(p.saying); } name.Text = ""; }
private void okButton_Click(object sender, RoutedEventArgs e) { words.Text = ""; c = new cat(words); d = new dog(words); p = new pig(words); //获取输入 string inputAnimal = this.textBox.Text; if (inputAnimal == "cat") { Say -= new AnimalSaying(d.saying); Say -= new AnimalSaying(p.saying); Say += new AnimalSaying(c.saying); } else if (inputAnimal == "dog") { Say -= new AnimalSaying(c.saying); Say -= new AnimalSaying(p.saying); Say += new AnimalSaying(d.saying); } else if (inputAnimal == "pig") { Say -= new AnimalSaying(c.saying); Say -= new AnimalSaying(d.saying); Say += new AnimalSaying(p.saying); } this.textBox.Text = ""; //执行事件 Say(this, new myEventArgs()); }
private void sure_btn_Click(object sender, RoutedEventArgs e) { this.textBlock.Text = ""; string name = this.textBox.Text; switch (name) { case "pig": p = new pig(textBlock); Speak += new animal_speak(p.saying); break; case "dog": d = new dog(textBlock); Speak += new animal_speak(d.saying); break; case "cat": c = new cat(textBlock); Speak += new animal_speak(c.saying); break; default: this.textBox.Text = ""; return; } Speak(this, new EventArgs()); switch (name) { case "pig": Speak -= new animal_speak(p.saying); break; case "dog": Speak -= new animal_speak(d.saying); break; case "cat": Speak -= new animal_speak(c.saying); break; default: return; } this.textBox.Text = ""; }
public IHttpActionResult Putdog(int id, dog dog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dog.id) { return(BadRequest()); } db.Entry(dog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!dogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static void Main() { dog dog = new dog(); cat cat = new cat(); process.Call(dog); //1 }
private void button1_Click(object sender, RoutedEventArgs e) { if (c == null) { c = new cat(words); d = new dog(words); p = new pig(words); } if (textBox.Text == "cat") { words.Text = ""; Say += new AnimalSaying(c.saying); Say(this, EventArgs.Empty); textBox.Text = ""; } else if (textBox.Text == "dog") { words.Text = ""; Say += new AnimalSaying(d.saying); Say(this, EventArgs.Empty); textBox.Text = ""; } else if (textBox.Text == "pig") { words.Text = ""; Say += new AnimalSaying(p.saying); Say(this, EventArgs.Empty); textBox.Text = ""; } }
private void button_sure_Click(object sender, RoutedEventArgs e) { string s = who.Text; if (s == "cat") { c = new cat(words); Say = new AnimalSaying(c.saying); } else if (s == "dog") { d = new dog(words); Say = new AnimalSaying(d.saying); } else if (s == "pig") { p = new pig(words); Say = new AnimalSaying(p.saying); } else { who.Text = ""; return; } Say(this); scroll.ChangeView(null, scroll.ScrollableHeight, null); who.Text = ""; }
private void button1_Click(object sender, RoutedEventArgs e) { int flag = 0; if (times % 18 == 0) { textBlock.Text = ""; } if (textBox.Text == "cat") { c = new cat(textBlock); Say += new AnimalSaying(c.saying); } else if (textBox.Text == "dog") { d = new dog(textBlock); Say += new AnimalSaying(d.saying); } else if (textBox.Text == "pig") { p = new pig(textBlock); Say += new AnimalSaying(p.saying); } else { flag = 1; } if (flag != 1) { Say(this, new myEventArgs(times++)); Say = null; } textBox.Text = ""; }
private void button_Click(object sender, RoutedEventArgs e) { c = new cat(textBlock); d = new dog(textBlock); p = new pig(textBlock); Random ran = new Random(); int RandKey = ran.Next(1, 4); switch (RandKey) { case 1: Say += new AnimalSay(c.say); break; case 2: Say += new AnimalSay(d.say); break; case 3: Say += new AnimalSay(p.say); break; } Say(this); Say = null; }
public void BeinggroomTest19001() { dog dog; dog = new dog(""); this.BeinggroomTest(dog); Assert.IsNotNull((object)dog); }
public void provideservTest886() { dog dog; dog = new dog((string)null); this.provideservTest(dog, Dogservices.fullgroom); Assert.IsNotNull((object)dog); }
public static void Main() { dog dog = new dog(); cat cat = new cat(); Call(dog); Console.ReadLine(); }
static void Main1(string[] args) { dog mydog = new dog(); animal thePet = mydog; thePet.sound();//.eat(); mydog.sound(); }