Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help creating the code for object oriented programming in C# called monst

ID: 3885375 • Letter: I

Question

I need help creating the code for object oriented programming in C# called monster. I am using visual studio 2017.

Tasks: Do the reading tutorial on Learn. In doing this tutorial remember to label your namespace LastnameFirstname.Game (please do not turn in an assignment with the namespace FlorNick.Game or I'll mark you down significantly!) Create a class monster that inherits from thing. Override thing's move0 and draw0. and change their implementations. The implementation specifics are up to you, just don't reuse thing and player's move & draw coe. 1. 2. 3. Zip your homework folder and upload the zipped file to LEARN

Explanation / Answer

Prog1.cs

// namespace specifies how to group objects.

// System namespace specifies fundamental and base classes that consists of value and reference data types, event handlers, interfaces and how to handle exceptions

using System;// use any namespace using 'using' keyword
//namespace declaration
//parent class
namespace VenuRaju.Game
{
//class declaration
class thing
{
// Attributes
protected int x,y;//protected specifies data should be accessible in parent class and in immediate derived class
//Constructors- used to initialize the object of particular class
public thing()
{
Random r;
r=new Random();//initializing Random class
x=r.Next(1,100);//Pick up random number from 1 to 100
y=r.Next(1,100);
}
//Methods
public virtual void move()
{
x=x+1;
y=y+1;
}
public virtual void draw()
{
Console.WriteLine(String.Format("T {0},{1}",x,y));
}
}
}
//namespace declaration
//parent class
namespace VenuRaju.Game
{
//child class declaration inheriting from parent class
class monster:thing
{
//attribute
int[] numbers;//declare numbers array
//Constructor- used to initialize the object of particular class
public monster()
{
numbers=new int[5]{5,1,8,6,9};// initialize numbers with size 5 and storing 5 elements
x=numbers[3];//storing one of elements in number array in x and y
y=numbers[1];
}
//Methods overriding from parent class use override keyword
public override void move()
{
for(int i=0;i<5;++i)
{
x=x*2+numbers[i];
y=y*2+numbers[i];
}
}
public override void draw()
{
Console.WriteLine("Position of X-axis for Monster is");
Console.WriteLine(x);
Console.WriteLine("Position of Y-axis for Monster is");
Console.WriteLine(y);
}
}
}

Main.cs

using System;

using VenuRaju.Game;// using userdefined namespace

class Mainprogram
{
static void Main()//executing program
{
thing obj=new thing();//creating object for parent class
// calls parent class move and draw methods
obj.move();
obj.draw();
obj=new monster();//parent class object is refering to child class this concept is explaining usage of polymorphism
//calls child class move and draw methods
obj.move();
obj.draw();
}
}

Output


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote