Respuesta :
Dog can do tricks For this lab we once again are going to create 2 classes, 1 called Dog and 1 called Lab10B. And the function is given below.
What is function?
A function is a logical, reusable section of code that executes a single, connected action. In addition to a high level of code reuse, functions improve the modularity of your application.
You have already encountered a number of functions, including printf() and main ().
These are referred to as built-in functions that the language itself offers, but we can also create our own functions. This tutorial will show you how to do both in the C programming language.
//C# Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lab10b{
class Dog
{
public int age;
public double weight;
public string name;
public string furColor;
public string breed;
public void bark()
{
Console.WriteLine("Woof! Woof!");
}
public void rename(string name)
{ this.name = name;
}
public void eat(double food)
{ weight += food;
}
}
class Lab10B
{ static void Main(string[] args)
{ Dog dog = new Dog();
Console.WriteLine("You are about to create a dog.");
Console.Write("How old is the dog:: ");
dog.age = int.Parse(Console.ReadLine());
Console.Write("How much does the dog weigh: ");
dog.weight = double.Parse(Console.ReadLine());
Console.Write("What is the dog’s name:: ");
dog.name = Console.ReadLine();
Console.Write("What color is the dog: ");
dog.furColor = Console.ReadLine();
Console.Write("What breed is the dog: ");
dog.breed = Console.ReadLine();
// print out all the details about the Dog
Console.WriteLine("{0} is a {1} year old {2} {3} that weighs {4} lbs.", dog.name,dog.age,dog.furColor,dog.breed,dog.weight);
dog.bark();
Console.Write("Patches is hungry, how much should he eat: ");
dog.eat(double.Parse(Console.ReadLine()));
Console.Write("Patches isn’t a very good name. What should they be renamed to: ");
dog.rename(Console.ReadLine());
Console.WriteLine("{0} is a {1} year old {2} {3} that weighs {4} lbs.", dog.name, dog.age, dog.furColor, dog.breed, dog.weight);
}
}
}
Learn more about function
https://brainly.com/question/20476366
#SPJ4