public async Task <IActionResult> Edit(int id, [Bind("ID,CanTalk,FeathersColor,Name,Gender,DateOfBirth,Weight")] Parrot parrot) { if (id != parrot.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parrot); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParrotExists(parrot.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(parrot)); }
/* * public class Bird * { * public string Name { get; private set; } * public string Color { get; private set; } * * public Bird(string name, string color) * { * Name = name; * Color = color; * } * * public void Speak() * { * Console.WriteLine($"My name is {Name} and I am a {Color} bird."); * } * * public void Fly() * { * Console.WriteLine($"I'm {Name} and I can fly high in the blue sky!"); * } * } * * public class Pigeon : Bird * { * //The Pigeon constructor calls the base class Bird constructor * //The name and color parameters are passed to the Bird constructor * public Pigeon(string name, string color) : base(name, color) * { * } * * public void EatPizza() * { * Console.WriteLine("Delicious pizza!"); * } * public void Sleep(string condition) * { * string Condition = condition; * Console.WriteLine($"im a {Condition} sleepy bird :)"); * } * * } * */ static void Main(string[] args) { Pigeon pippa = new Pigeon("Pippa", "Grey"); pippa.Speak(); pippa.Fly(); pippa.EatPizza(); pippa.Spin(); pippa.DoTheCaterpillar(); pippa.Jump(); Penguin pingu = new Penguin("Pingu", "Black & White"); pingu.Speak(); pingu.Fly(); pingu.Spin(); Parrot rio = new Parrot("rio", "blue"); rio.Speak(); rio.Spin(); pingu.Jump(); #if DEBUG Console.WriteLine("\nPress enter to close..."); Console.ReadLine(); #endif }
static void Main(string[] args) { Console.WriteLine("Welcome Home!"); Console.WriteLine(); Console.ReadKey(); Dog dog = new Dog("Jacob", 25); dog.Voice(); dog.GetInfo(); Console.WriteLine(); Console.ReadKey(); Cat cat = new Cat("Pushok", 84); cat.Voice(); cat.GetInfo(); Console.WriteLine(); Console.ReadKey(); Parrot parrot = new Parrot("Mihalich", 2); parrot.Voice(); parrot.GetInfo(); Console.WriteLine(); Console.ReadKey(); Bird bird = new Bird("Konoreyca", 3); bird.Voice(); bird.GetInfo(); Console.WriteLine(); Console.ReadKey(); }
static void Main(string[] args) { IFly popper = new Penguin("Spheniscidae", 8); Parrot tweety = new Parrot("Tweety", "yellow"); Squirrel squirrel = new Squirrel(); Dictionary <string, List <IFly> > FlyingCreatures = new Dictionary <string, List <IFly> >(); List <IFly> birds = new List <IFly>() { popper, tweety }; // birds.Add(popper); // birds.Add(tweety); FlyingCreatures["birds"] = birds; FlyingCreatures["non-birds"] = new List <IFly>() { squirrel, tweety }; //Itterates over object keys and values calling each pair 'types' foreach (KeyValuePair <string, List <IFly> > types in FlyingCreatures) { System.Console.WriteLine(types.Key); //Itterates over inner lists for (int i = 0; i < types.Value.Count; i++) { types.Value[i].Fly(); } } }
public bool GetValue(IDictionary<string, object> documentHost, object model, Parrot.Infrastructure.ValueType valueType, object property, out object value) { switch (valueType) { case Parrot.Infrastructure.ValueType.StringLiteral: case Parrot.Infrastructure.ValueType.Keyword: value = property; return true; case Parrot.Infrastructure.ValueType.Local: value = model; return true; case Parrot.Infrastructure.ValueType.Property: if (model == null) { throw new NullReferenceException("model"); } var propertyValues = (IDictionary<string, object>) model; var result = model; var properties = property.ToString().Split(".".ToCharArray()); for (int i = 0; i < properties.Length; i++) { var name = properties[i]; result = propertyValues[name]; propertyValues = result as IDictionary<string, object>; } value = result; return true; } value = null; return false; }
public void TestParrot() { Parrot parrot = new Parrot(); Assert.Equal("Parrots live in the Amazon!", parrot.TropicalHabitat); Assert.True(parrot.ColorfulPlumage); }
static void Main(string[] args) { cows cows1 = new cows("senior Elvis(the cows leader)", "moo", " fresh grass", "meat:"); cows cows2 = new cows(" Mrs Molly","moo", "chick fillet", " milk"); cows cows3 = new cows("Bossy","moo", "Maize" ,"cheese"); cows cows4 = new cows("Lovabull","moo","cabbage","leather"); cows cows5 = new cows("Raven","moo", "spinach", "fertilizer"); Console.WriteLine("Welcome to YAMBA's Farm,here are my special cows"); Console.WriteLine(cows1.GetName(), cows1.eatIT(),cows1.aProduce()); Console.WriteLine(cows2.GetName(), cows2.eatIT(),cows2.aProduce()); Console.WriteLine(cows3.GetName(), cows3.eatIT(),cows3.aProduce()); Console.WriteLine(cows4.GetName(), cows4.eatIT(), cows4.aProduce()); Console.WriteLine(cows5.GetName(), cows5.eatIT(), cows5.aProduce()); Console.WriteLine("*******************************************************************************"); Console.WriteLine("We have a variaty of animals like these ones: "); chicken chicken = new chicken("Jordan", "cluck"); Console.WriteLine(chicken.speakUp()); Rabbit Rabbit = new Rabbit("Gerald", "squeak"); Console.WriteLine(Rabbit.speakUp()); Lamb lamb = new Lamb("Travis", "bleat"); Console.WriteLine(lamb.speakUp()); Turkey Turkey = new Turkey("Siguel", "globble"); Console.WriteLine(Turkey.speakUp()); Parrot Parrot = new Parrot("Brice", "squawk"); Console.WriteLine(Parrot.speakUp()); Console.ReadLine(); }
/// <summary> /// Creates a new animal for a user based on the <c>AnimalRequest</c>. /// The enum value given there for the type of animal determines what kind of animal class is created /// </summary> /// <param name="animalRequest">the request that contains which type of animal and for which user.</param> /// <returns>the new <c>Animal</c> entity</returns> public Animal AddAnimal(AnimalRequest animalRequest) { assertUserExists(animalRequest); //TODO: better with string instead of enum numbers? Animal.AnimalType animalType = animalRequest.Type; //(Animal.AnimalType)Enum.ToObject(typeof(Animal.AnimalType), type); Animal newPet; switch (animalType) { case Animal.AnimalType.Cat: newPet = new Cat(); break; case Animal.AnimalType.Dog: newPet = new Dog(); break; case Animal.AnimalType.Parrot: newPet = new Parrot(); break; default: throw new ArgumentException("Could not create specific animal type. Enum value is not handled."); } logger.LogInformation("Creating a new animal of type {0} for user {1}", new object[] { animalType.ToString(), animalRequest.UserId.ToString() }); newPet.Name = animalRequest.Name; newPet.UserId = animalRequest.UserId; databaseService.AddAnimal(newPet); return(newPet); }
public bool GetValue(IDictionary<string, object> documentHost, object model, Parrot.Infrastructure.ValueType valueType, object property, out object value) { switch (valueType) { case Parrot.Infrastructure.ValueType.StringLiteral: case Parrot.Infrastructure.ValueType.Keyword: value = property; return true; case Parrot.Infrastructure.ValueType.Local: value = model; return true; case Parrot.Infrastructure.ValueType.Property: if (model != null && GetModelProperty(model, property, out value)) { return true; } if (documentHost != null && GetModelProperty(documentHost, property, out value)) { return true; } value = null; return false; } value = model; return false; }
private Animal CreateTestAnimal(ulong userId) { Animal anim = new Parrot(); anim.UserId = userId; return(anim); }
void Start() //Use this for initialization { parrot = gameObject.GetComponent <Parrot>(); items = new List <GameObject>(); itemsRB = new List <Rigidbody>(); itemsScripts = new List <Item>(); itemHalfHeight = new List <float>(); GameObject[] foundItems = GameObject.FindGameObjectsWithTag("Item"); for (int i = 0; i < foundItems.Length; i++) //Get all of the needed item componenets { items.Add(foundItems[i]); //The item itemsRB.Add(foundItems[i].GetComponent <Rigidbody>()); //The item's rigidbody itemsScripts.Add(foundItems[i].GetComponent <Item>()); //The script on the item itemHalfHeight.Add(foundItems[i].GetComponent <Collider>().bounds.size.y / 2); //Half of the Y value of the colider on the item } carriedItem = null; carriedItemRB = null; carriedItemHalfHeight = 0; if (gameObject.tag == "Parrot1") { itemSlot = GameObject.FindGameObjectWithTag("ItemSlot1").transform; } else if (gameObject.tag == "Parrot2") { itemSlot = GameObject.FindGameObjectWithTag("ItemSlot2").transform; } buttonDown = false; }
public async Task <IActionResult> Edit(int id, [Bind("ParrotId,Name,Species,Breeder,Cost,Gender,Sold,Deceased,OldWorld,NewWorld")] Parrot parrot) { if (id != parrot.ParrotId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parrot); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParrotExists(parrot.ParrotId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(parrot)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Quantity,TypeDescription,KindID")] Parrot parrot) { if (id != parrot.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parrot); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParrotExists(parrot.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["KindID"] = new SelectList(_context.KindOfParrots, "ID", "Name", parrot.KindID); return(View(parrot)); }
public static String BoxParrotString(Parrot parrot, Parrot_String str) { IntPtr pmc_ptr = IntPtr.Zero; int result = Parrot_api_pmc_box_string(parrot.RawPointer, str.RawPointer, out pmc_ptr); if (result != 1) parrot.GetErrorResult(); return new String(parrot, pmc_ptr); }
public ActionResult DeleteConfirmed(int id) { Parrot parrot = db.Parrots.Find(id); db.Parrots.Remove(parrot); db.SaveChanges(); return(RedirectToAction("Index")); }
public static Class GetClassPMC(Parrot parrot, Parrot_PMC key) { IntPtr class_ptr = IntPtr.Zero; int result = Parrot_api_pmc_get_class(parrot.RawPointer, key.RawPointer, out class_ptr); if (result != 1) parrot.GetErrorResult(); // This could be a Class or a PMCProxy, but for our purposes we treat them the same. return new Class(parrot, class_ptr); }
public override void Render(Parrot.Infrastructure.IParrotWriter writer, IRendererFactory rendererFactory, Nodes.Statement statement, IDictionary<string, object> documentHost, object model) { var localModel = GetLocalModel(documentHost, statement, model); if (localModel is bool && (bool)localModel) { RenderChildren(writer, statement.Children, rendererFactory, documentHost, base.DefaultChildTag, model); } }
private static void h_TestPolymorph() { Animal pAnimal; pAnimal = new Cow(); h_MakeNoise(pAnimal); pAnimal = new Parrot(); h_MakeNoise(pAnimal); }
static void Main(string[] args) { var dalmatian = new Dog { name = "Tilde", price = 200, color = "White and black", species = "Dalmatian" }; var cockatoo = new Parrot { name = "Charlie", price = 75, color = "Grey", species = "Cockatoo" }; var anaconda = new Snake { name = "Nagini", price = 150, color = "Green/Brown", species = "Anaconda" }; var dogBowl = new FoodBowl { name = "Food bowl for dogs", price = 50, color = "Metallic Grey", brandName = "AnimalsBFF", animalType = "Dogs" }; var birdBowl = new FoodBowl { name = "Food bowl for birds", price = 25, color = "Metallic Grey", brandName = "AnimalsBFF", animalType = "Birds" }; var snakeBowl = new FoodBowl { name = "Food bowl for snakes", price = 25, color = "Metallic Grey", brandName = "AnimalsBFF", animalType = "Snakes" }; productsList.AddRange(new Products[] { dalmatian, cockatoo, anaconda, dogBowl, birdBowl, snakeBowl });//products added to the shops inventory while (true) { mainMenu(); } }
// Use this for initialization void Start() { _finishedText = GameObject.Find("FinishedText").GetComponent <Text>(); _timeText = GameObject.Find("TimeText").GetComponent <Text>(); _finishedText.enabled = false; _startTime = Time.time; _playerBird = GameObject.FindGameObjectsWithTag("Player").Single(); _playerScript = _playerBird.GetComponent <Parrot>(); _cheerAudio = GetComponent <AudioSource>(); }
public static void playWithAnimals() { var imbirchik = new Hedgehog(); imbirchik.MakeFunnySound(); var toree = new Parrot(); toree.MakeFunnySound(); }
public ActionResult Edit([Bind(Include = "Id,Name,Age,Color,CageId")] Parrot parrot) { if (ModelState.IsValid) { db.Entry(parrot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CageId = new SelectList(db.Cages, "CageId", "Name", parrot.CageId); return(View(parrot)); }
static void OverrideAbstractProperties() { Toucan toucan = new Toucan(); Console.WriteLine($"A toucan has colorful plumage: {toucan.ColorfulPlumage}"); Console.WriteLine($"{toucan.TropicalHabitat}"); Parrot parrot = new Parrot(); Console.WriteLine($"A parrot has colorful plumage: {parrot.ColorfulPlumage}"); Console.WriteLine($"{parrot.TropicalHabitat}"); }
public async Task <IActionResult> Create([Bind("ParrotId,Name,Species,Breeder,Cost,Gender,Sold,Deceased,OldWorld,NewWorld")] Parrot parrot) { if (ModelState.IsValid) { _context.Add(parrot); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(parrot)); }
public async Task <IActionResult> Create([Bind("ID,CanTalk,FeathersColor,Name,Gender,DateOfBirth,Weight")] Parrot parrot) { if (ModelState.IsValid) { _context.Add(parrot); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(parrot)); }
public ActionResult Create([Bind(Include = "Id,Name,Age,Color,CageId")] Parrot parrot) { if (ModelState.IsValid) { db.Parrots.Add(parrot); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CageId = new SelectList(db.Cages, "CageId", "Name", parrot.CageId); return(View(parrot)); }
public async Task <IActionResult> Create([Bind("ID,Quantity,TypeDescription,KindID")] Parrot parrot) { if (ModelState.IsValid) { _context.Add(parrot); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["KindID"] = new SelectList(_context.KindOfParrots, "ID", "Name", parrot.KindID); return(View(parrot)); }
static void Main() { // A new instance of the Parrot class with integer // 450 is created and assigned to the variable // 'parrot'. The Parrot class' constructor will // print out the integer value in its method // result. However, it will also call the Bird // class' method as the base class constructor // is automatically invoked. Parrot parrot = new Parrot(450); Console.WriteLine(":::DONE:::"); }
public static void Main(string[] args) { // Old style, procedural code: /* * var animal1Name = "Sasha"; * var animal1Breed = "Cheagle"; * var animal1Type = "dog"; * var animal2Name = "Polly"; * var animal2Breed = (string)null; * var animal2Type = "bird"; * // etc * Move(animal1Name, animal1Type); * Move(animal2Name, animal2Type); * */ var sashaTheDog = new Dog("Sasha", "Cheagle", "chicken", Gender.Female); sashaTheDog.Eat("kibble"); sashaTheDog.Eat("chicken"); sashaTheDog.MakeNoise(); sashaTheDog.DoTrick(); sashaTheDog.DoTrick("Play Dead"); sashaTheDog.DoTrick("Run Around"); sashaTheDog.Eat("kibble"); sashaTheDog.Eat("chicken"); var polly = new Parrot("Patrick", "blue", Gender.Male); polly.Eat("Kibble"); polly.Eat("Steak"); polly.Eat("seeds"); polly.Fly(); polly.Eat("seeds"); polly.Speak(); polly.LearnPhrase("want a cracker?"); polly.Speak(); polly.LearnPhrase("ARRR MATEY"); polly.LearnPhrase("Help! I'm trapped in a parrot's body!"); polly.LearnPhrase("ARRR MATEY"); polly.Speak(); polly.Speak(); polly.Speak(); polly.Speak(); #if DEBUG Console.WriteLine("Press enter to close..."); Console.ReadLine(); #endif }
// GET: Parrots/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Parrot parrot = db.Parrots.Find(id); if (parrot == null) { return(HttpNotFound()); } return(View(parrot)); }
static void Main(string[] args) { // Writes Woof, Woof IAnimal animal = new Dog(); Console.WriteLine(animal.Speak()); // Now writes Meow animal = new Cat(); Console.WriteLine(animal.Speak()); // Now writes Sqwark etc animal = new Parrot(); Console.WriteLine(animal.Speak()); }
// GET: Parrots/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Parrot parrot = db.Parrots.Find(id); if (parrot == null) { return(HttpNotFound()); } ViewBag.CageId = new SelectList(db.Cages, "CageId", "Name", parrot.CageId); return(View(parrot)); }
static void Main(string[] args) { Dog dog = new Dog(); Male male = new Male(); Parrot parrot = new Parrot(); ParrotAdapter parrotAdapter = new ParrotAdapter(parrot); dog.MakeSound("Bhow Bhow!"); male.SpeakWords("Ssup dude!"); parrot.MakeSound("Phew!"); // parrot should not 'make sound', it should 'speak words' parrotAdapter.SpeakWords("Hey, parrot can speak."); Console.ReadLine(); }
static void Main(string[] args) { string name; Console.Write("Pirate's name? "); name = Console.ReadLine(); Pirate pirate = new Pirate(name); // test Pirate constructor Console.Write("Parrot's name? "); name = Console.ReadLine(); Parrot parrot = new Parrot(name); // test Parrot constructor // Test "name" and "speak" methods in both Pirate and Parrot: Console.WriteLine(pirate.getName() + " says " + pirate.speak()); Console.WriteLine(pirate.getName() + "'s parrot, " + parrot.getName() + ", says " + parrot.speak()); }
static void Main(string[] args) { //Dog dog = new Dog("Владос", 5000, 0.4f); //Cat cat = new Cat("Смэрть", 5000, 0.4f); //dog.Damage = 100; //cat.Damage = 90; //Fight(dog, cat);' HomeAnimal[] animals = new HomeAnimal[3]; animals[0] = new Dog("Master", 100, 0.2f, 10); animals[1] = new Cat("Shadow", 100, 0.5f, 10); animals[2] = new Parrot("Death"); animals[1].Hit(animals[2]); animals[0].Hit(animals[1]); animals[1].Heal(10); }
public object GetValue(object model, Parrot.Infrastructure.ValueType valueType, object property) { switch (valueType) { case Parrot.Infrastructure.ValueType.StringLiteral: case Parrot.Infrastructure.ValueType.Keyword: return property; case Parrot.Infrastructure.ValueType.Local: return model; case Parrot.Infrastructure.ValueType.Property: if (model == null) { throw new NullReferenceException("model"); } return GetModelProperty(model, property); } throw new InvalidOperationException("ValueType"); }
protected override void CreateTag(Parrot.Infrastructure.IParrotWriter writer, IRendererFactory rendererFactory, IDictionary<string, object> documentHost, object model, Nodes.Statement statement) { var xhtml = false; if (documentHost.ContainsKey("doctype")) { //we have a registered doctype, is it xml? if (documentHost["doctype"].ToString().IndexOf("xhtml", StringComparison.OrdinalIgnoreCase) != -1) { //it's xhtml, we need to output cdata xhtml = true; } } string tagName = string.IsNullOrWhiteSpace(statement.Name) ? DefaultChildTag : statement.Name; TagBuilder builder = new TagBuilder(tagName); //add attributes RenderAttributes(rendererFactory, documentHost, model, statement, builder); //AppendAttributes(builder, statement.Attributes, documentHost, modelValueProvider); writer.Write(builder.ToString(TagRenderMode.StartTag)); //render children if (xhtml) { writer.Write("//<![CDATA["); } if (statement.Children.Count > 0) { RenderChildren(writer, statement, rendererFactory, documentHost, model); } if (xhtml) { writer.Write("//]]>"); } writer.Write(builder.ToString(TagRenderMode.EndTag)); }
public Exception(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public static IPMCFactory<Integer> GetFactory(Parrot parrot) { return new PMCFactory<Integer>(parrot, "Integer"); }
public Sub(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public Class(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public static IPMCFactory<CallContext> GetFactory(Parrot parrot) { return new PMCFactory<CallContext>(parrot, "CallContext"); }
public static IPMCFactory GetFactory(Parrot parrot) { return new PMCFactory<Sub>(parrot, "Sub"); }
public CallContext(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public static IPMCFactory<String> GetFactory(Parrot parrot) { return new PMCFactory<String>(parrot, "String"); }
public Null(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public Interpreter(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public PackFile(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }
public static IPMCFactory<Class> GetFactory(Parrot parrot) { return new PMCFactory<Class>(parrot, "Class"); }
public String(Parrot parrot, IntPtr ptr) : base(parrot, ptr) { }