Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:50:00+00:00 2026-06-09T15:50:00+00:00

as you guys can see from the code i created three classes car,new model,main

  • 0

as you guys can see from the code i created three classes car,new model,main . all the basic methods are in car class , i created the inherited class to try (inheritance). as you can see what i am doing is just output the wheel() method of car class with newrims() method of newmodel inherited class to make a complete sentence.need suggestion to make the code more accurate.

namespace ConsoleApplication4
{
   public class car
   {
    public static void wheel()
    {
        Console.WriteLine("The wheels are rolling");
    }
    public static void doors()
    {
        Console.WriteLine("The Doors are automatic");
    }
    public static void engine()
    {
        Console.WriteLine("The engine of car is runing");
    }
    public static void oil()
    {
        Console.WriteLine("the oil is full in tank");
    }
   }
   public class newmodel : car
   { 
    public static void newrims()
    {
        car.wheel();
        Console.WriteLine("And The new rims are rocking");
    }

  }

  class Program
  {
      static void Main()
      {
         while (true)
         {
            Console.WriteLine("Press A to Roll the Wheels baby");
            Console.WriteLine("Press B to Open/Close the Doors");
            Console.WriteLine("Press C to Start the Car Engine");
            Console.WriteLine("Press D to Check the Oil in tank");
            Console.WriteLine("Press E to Rims/wheels");
            Console.WriteLine("Press F to Exit the vehicle");
            char c = Convert.ToChar(Console.ReadLine());
            switch (c)
            {
                case 'a':
                    {
                        car.wheel();
                        break;
                    }
                case 'b':
                    {
                        car.doors();
                        break;
                    }
                case 'c':
                    {
                        car.engine();
                        break;
                    }
                case 'd':
                    {
                        car.oil();
                        break;
                    }
                case 'e':
                    {
                        newmodel.newrims();
                        break;
                    }
                case 'f':
                    {
                        Environment.Exit(0);
                        break;
                    }
                default:
                    {
                        Console.WriteLine("Please Enter the Correct Input");
                        break;
                    }
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:50:01+00:00Added an answer on June 9, 2026 at 3:50 pm

    An example of inheritance in your case would be something like this

    namespace ConsoleApplication4
    {
        public class car
        {
            //note the absence of static keyword..it means it is an instance method
            //note the virtual keyword..it means derived classes can override the behavior
            public virtual void wheel()
            {
                Console.WriteLine("The wheels of car are rolling");
            }
    
        }
    
        public class newmodel : car
        {
            //note the override keyword....it means newmodel overrides the wheel function
            public override void wheel()
            {
                //depending on your needs you may or maynot 
                // need to call the base class function first
                base.wheel();
                Console.WriteLine("And The new rims are rocking");
            }
    
        }
    
        class Program
        {
            static void Main()
            {
                //Instead of static methods you create a car object on
                //on which you invoke member functions
                car currentcar = new car();
                while (true)
                {
                    Console.WriteLine("Press A to Roll the Wheels baby");
                    Console.WriteLine("Press N to switch to new model");
                    char c = Convert.ToChar(Console.ReadLine());
                    switch (c)
                    {
                        case 'a':
                            {
                                currentcar.wheel();
                                break;
                            }
                        case 'n':
                            {
                                currentcar = new newmodel();
                                break;
                            }
                        default:
                            {
                                Console.WriteLine("Please Enter the Correct Input");
                                break;
                            }
    
                    }
                }
            }
        }
    }
    

    As you will notice that pressing a will call the wheel function but depending on whether your car is the plain old car or the new model it will print different things to the Console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I can't provide the code but you can see it on the
so guys, if u test the code below, u can see that everything is
I will keep the code simple so that you guys can see what I'm
HI Guys, I have created a windows service which spawns three threads.The first thread
As you can see from the title I basically want to update a plist.
I'm trying to setup a very basic jQuery image gallery. You can see my
hi guys can anyone guide me on implementation of Internationalization on Android platform. I
I'm hoping you guys can answer me a question? I've only just started out
I'm hoping you guys can help me figure out why this is happening. I've
Maybe you guys can help: I have a variable called $bio with bio data.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.