Click here to Skip to main content
15,896,493 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Can someone help me with this Stackoverflowexception problem . I have no idea what to do , I'm new to programing. Here is my code:

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

namespace Domasno1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Motorni vozila");
            Avtomobil Gt200 = new Avtomobil( 270, "A9motor", "sportcar", 2, "Ferari");
            Avtomobil Golf5 = new Avtomobil(170, "A3motor", "normalcar", 4, "Golf");
            Avtobus Man1 = new Avtobus("ManBUS3", 2, "MANBUSES", 2, 13,160);
            Avtobus Scul = new Avtobus("Scul1", 4, "Sculamat", 3, 20,220);

            Gt200.Info();
            Golf5.Info();
            Man1.Info();
            Scul.Info();

            Console.Write("Po dve godini motorot oslabuva i brzinata se namaluva");
            Thread.Sleep(5000);

            Gt200._brzina = 230;
            Golf5._brzina = 130;
            Man1._brzina = 120;
            Scul._brzina = 160;

            Console.WriteLine("");
            Console.WriteLine("-------------------------------------------");

            Gt200.Info();
            Golf5.Info();
            Man1.Info();
            Scul.Info();

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();


        }

        public class Motornovozilo
        {
            private string tipnavozilo;
            private int brvrati;
            private string marka;

            protected Motornovozilo()
            {

            }
            protected Motornovozilo(string tip,int vrati, string _marka)
            {
                tip = tipnavozilo;
                brvrati = vrati;
                marka = _marka;
            }

            public string tip
            {
                get{return tip;}
                set{tip = value;}
            }

            public int vrati
            {
                get{return brvrati;}
                set{brvrati = value;}
            }

            public string _marka
            {
                get{return marka;}
                set{marka = value;}
            }
        }

        public class Avtomobil : Motornovozilo
        {
            private int brzina;
            private string motor;



            public Avtomobil(int _brzina, string _motor, string tip, int vrati, string _marka)
            {
                brzina = _brzina;
                motor = _motor;
            }

            public int _brzina
            {
                get { return brzina; }
                set { brzina = value; }
            }
            public string _motor
            {
                get { return motor; }
                set { motor = value; }
            }

            public string Info()
            {
                return "Avtomobilot e " + _marka + " ,ima motor " + motor + ". Ima " + vrati + " vrati" +
                    " i ovoj avtomobil e " + tip + " i moze da dostigne do " + _brzina + " km/h";
            }

        }

        public class Avtobus : Motornovozilo 
        {
            private int visina;
            private int dolzina;
            private int brzina;

            
            public Avtobus(string tip,int vrati, string _marka,int _visina,int _dolzina , int _brzina)
            {
                visina = _visina;
                dolzina = _dolzina;
                brzina = _brzina;
            }

            public int _visina
            {
                get{return visina;}
                set{visina = value;}
            }
            
            public int _brzina
            {
                get { return brzina; }
                set { brzina = value; }
            }

            public string Info()
            {
                return "Avtobusot e " + _marka + " ,ima visina " + _visina + "m" + ". Ima " + vrati + " vrati"
                    + " i ovoj avtobus e " + tip + " ,a dolg e  " + dolzina + " m." + " Moze da dostigne do " + _brzina;
            }


        }
    }
}


When I run my application
http://prntscr.com/ari1m6[^]

What I have tried:

I have no idea what to do , I'm new to C# programing.
Posted
Updated 12-Apr-16 11:17am
v2

One of the first things to check is properties...

C#
public string tip
{
  get{return tip;}
  set{tip = value;}
}
 
Share this answer
 
Comments
CPallini 12-Apr-16 17:20pm    
5.
Dee run 12-Apr-16 17:22pm    
Thanks guys I have fixed it.
Sergey Alexandrovich Kryukov 12-Apr-16 18:37pm    
Ha-ha, a 5. :-)
—SA
I think it is time for you to stop guessing what your code is doing. It is time to see your code executing and ensuring that it does what you expect.

The debugger is your friend. It will show you what your code is really doing.
Follow the execution step by step, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900