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 8804533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:37:49+00:00 2026-06-14T01:37:49+00:00

I currently have a problem where my program should show parameters from each class

  • 0

I currently have a problem where my program should show parameters from each class onto the form, however the class lowest in the hierarchy isn’t showing. For example; I want it to show “Charity Cyclist No. 1 riding a tricycle with 3 wheels and £300 sponsorship” but it’s only showing “Charity Cyclist No. 1 riding a tricycle with 3 wheels”.

Here is my Sponsorship class:

class Sponsorship : CharityCyclists
{
    private double fundsRaised;

    public double FundsRaised
    {
        get { return fundsRaised; }
        set { fundsRaised = value; }
    }

    public Sponsorship(String type, int number, String finished, int hours, int mins, int secs, string bicycle, int wheels, double fundsRaised) : base(type, number, finished, hours, mins, secs, bicycle, wheels, fundsRaised)
    {
        this.fundsRaised = fundsRaised;
    }

    public override string ToString()
    {
        return base.ToString() + " and sponsorship amount: " + fundsRaised;
    }
}

Here is my CharityCyclists class:

class CharityCyclists : Cyclists
{

    private string bicycle;
    private int wheels;

    public string Bicycle
    {
        get { return bicycle; }
        set { bicycle = value; }
    }

    public int Wheels
    {
        get { return wheels; }
        set { wheels = value; }
    }


    public CharityCyclists(string type, int number, string finished, int hours, int mins, int secs, string bicycle, int wheels, double fundsRaised) : base(type, number, finished, hours, mins, secs)
    {
        this.bicycle = bicycle;
        this.wheels = wheels;
    }

    public override string ToString()
    {
        return base.ToString() + " riding a " + bicycle + " with " + wheels + " wheels";
    }
}

and my Cyclists class:

    public static int NumFinished
    {
        get { return Cyclists.numFinished; }
        set { Cyclists.numFinished = value; }
    }

    public string Type
    {
        get { return type; }
        set { type = value; }
    }

    public int Number
    {
        get { return number; }
        set { number = value; }
    }

    public string Finished
    {
        get { return finished; }
        set { finished = value; }
    }

    public int Hours
    {
        get { return hours; }
        set { hours = value; }
    }

    public int Mins
    {
        get { return mins; }
        set { mins = value; }
    }

    public int Secs
    {
        get { return secs; }
        set { secs = value; }
    }

    public Cyclists(string type, int number, string finished, int hours, int mins, int secs)
    {
        this.type = type;
        this.number = number;
        this.finished = finished;
        this.hours = hours;
        this.mins = mins;
        this.secs = secs;
    }

    public override string ToString()
    {

        return type + " No. " + number;
    }

    public Cyclists()
    {

    }

This is where they are added to the listbox on the form:

        Cyclists[] cyclistsList;
        cyclistsList = new Cyclists[2];

        cyclistsList[0] = new CharityCyclists("Novelty Charity Cyclist", 1, "Not Finished", 0, 0, 0, "Tricycle", 2, 300);
        cyclistsList[1] = new CompetitiveCyclists("Competitive Cyclist", 1, "Not Finished", 0, 0, 0, 25, 2);

        for (int i = 0; i < MAX_CYCLISTS; i++)
        {
            lstCyclists.Items.Add(cyclistsList[i]);
        }

Thanks!

  • 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-14T01:37:50+00:00Added an answer on June 14, 2026 at 1:37 am

    You are not creating Sponsorship instances at all. At this moment you are calling ToString() override of a CharityCyclist class, not Sponsorship because of this constructor call: cyclistsList[0] = new CharityCyclists("Novelty Charity Cyclist", 1, "Not Finished", 0, 0, 0, "Tricycle", 2, 300); You should modify your code like this:

    Cyclists[] cyclistsList;
            cyclistsList = new Cyclists[2];
    
        cyclistsList[0] = new Sponsorship("Novelty Charity Cyclist", 1, "Not Finished", 0, 0, 0, "Tricycle", 2, 300);
        cyclistsList[1] = new CompetitiveCyclists("Competitive Cyclist", 1, "Not Finished", 0, 0, 0, 25, 2);
    
        for (int i = 0; i < MAX_CYCLISTS; i++)
        {
            lstCyclists.Items.Add(cyclistsList[i]);
        }
    

    It is about polymorphism, you need to make an instance of the class which overridden method you would like to be called.

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

Sidebar

Related Questions

I currently have a problem with my jgroups configuration, causing thousands of messages getting
I currently have a problem attepting to update a record within my database. I
I currently have a problem within PHP where I want to sort these posts
I am new to Rails routing and I currently have a problem and hope
I'm currently playing with reflection and I have problem with my short code: public
I currently have collision between 2 sprites working, using sprite.collidesWith(otherSprite) . The problem is
I have a problem with my jquery UI tabs currently only in Firefox 3.6.24
I have a problem that output string must be utf8-formatted, I am writing currently
i am currently working on a facebook game and i have a problem concerning
im currently creating a graph for an app, using coreplot and have a problem

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.