c# with Visual Studio Create an interface called IActions Create a public method
ID: 3721965 • Letter: C
Question
c# with Visual Studio Create an interface called IActions Create a public method called Holler - Takes in nothing - Returns a string Create a class called Person Implements the interface above - The method being implemented will return "The person says ‘ Hiya ‘ “ Create a class called Canine Implements the interface above - The method being implemented will return "Is frustrated that 'I disagree with your hypothesis' comes out as a Growl" On the form, create a function called DoSomething - Takes in the IActions interface as parameter named Incoming - Returns nothing - Will show a messagebox with the data returned from Incoming.Holler On the form have a button that Creates a dog Creates a persorn - Sends the dog to DoSomething Send the person to DoSomethingExplanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
public interface IActions //Interface defined here
{
String Hollar();
}
public class Person : IActions //class person implements IAction Interface
{
public String Hollar()
{
return "The person says 'Hiya'";
}
}
public class Canine : IActions //class Canine implements interface IAction
{
public String Hollar()
{
return "Is frustrated that 'I disagree with your hypothesis' comes out as a Growl";
}
}
public partial class Main : System.Web.UI.Page ///Main Class of Page Name
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void DoSomething(IActions Incoming)
{
MessageBox.Show(Incoming.Hollar()); //shows messagebox
}
public void dog_OnClick(Object sender, EventArgs e) // is called on button Create a dog
{
IActions Inc = new Canine();
DoSomething(Inc);
}
public void person_OnClick(Object sender, EventArgs e) //is called on button Create a person
{
IActions Inc = new Person();
DoSomething(Inc);
}
}
----aspx coding----
<asp:Button ID="dog" runat="server" Text="Create a dog" />
<asp:Button ID="person" runat="server" Text="Create a person" />
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.