• 0

C# Programming - my assignment was to write code making Fido bark 5 times (while loop) and run 10 times (for Loop)


Question

I am getting error messages and the code won't build.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment07
{using System; using System.Collections.Generic; using System.Linq; using System.Text; 
 
namespace Assignment07 {     class Dog     {         public void bark(string dogsName)         {             Console.WriteLine(dogsName + " is barking");         }         public void run(string dogsName)         {             Console.WriteLine(dogsName + " is running");         }     } 
 
    class Program     {         static void Main(string[] args)         { 
 
            Dog fido = new Dog(); 
 
            fido.bark("Fido"); 
 
            fido.run("Fido"); 
 
            Console.Write("Hit any key to close"); Console.ReadKey(true);         }     } } 

    class Dog
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Assignment 07");
            Console.WriteLine("This program is written by Vickie Primes");
        }

        public void bark (string dogsName)
        { 
            int barking = 0;
            while(barking < 5){
                barking = barking +1;
                {
                Console.WriteLine(dogsName + " is barking");
               
        public  string running { get; set; }}
      
                   
        public void Run(string dogsName)
        {
                for (var i = 0; i < 10; i++)
                running = "1 + 1";
                Console.WriteLine(dogsName + "is running");

            Dog fido = new Dog();

            fido.bark("Fido");

            fido.run("Fido");

            Console.Write("Hit any key to close"); Console.ReadKey(true);
        }
    
public  string running { get; set; }}
      
    
 

4 answers to this question

Recommended Posts

  • 0
using System;
namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var myDog = new Dog("Vickie");

            var barking = 0;
            while(barking < 5)
            {
                barking++;
                myDog.Bark();
            }

            for(var running = 0; running < 10; running ++)
            {
                myDog.Run();
            }
        }
    }

    class Dog
    {
        public string Name { get; set; }
        public Dog(string name)
        {
            Name = name;
        }
        public void Run() {
            Console.WriteLine(Name + " is running");
        }
        public void Bark() {
            Console.WriteLine(Name + " is barking");
        }
    }
}

LOL. Hope you become an awesome programmer one day :)

  • Like 1
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.