I am trying to simply create a base class for a top trumps card deck, But am getting an error from this line
Card1.Text = TopTrump1.height.ToString();
telling me that it's inaccessible due to protection level. I have tried manually chanding the text box properties from private to public but still same error. Below is a code dump of my game.cs, this is my first time working with multiple forms with multiple source files and I assume my ordering is probably wrong.
Any tips on tidying up code would be nice aswell, Thanks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TopTrumps
{
public partial class Game : Form
{
public class TopTrumps //Top trumps class
{
int height;
int length;
int speed;
public TopTrumps(int a, int b, int c) //Pass height length and speed as arguements to class
{
this.height = a; // Set objects height to the parsed value of a
this.length = b;
this.speed = c;
}
}
public Game()
{
InitializeComponent();
}
public static void DefineCards()
{
TopTrumps TopTrump1 = new TopTrumps(10, 20, 30);
}
public static void InitialiseDeck()
{
DefineCards();
}
private void Hide_Click(object sender, EventArgs e)
{
Form1 MainScreen = new Form1();
this.Hide();
MainScreen.ShowDialog();
}
public void DealCards_Click(object sender, EventArgs e)
{
TopTrumps TopTrump1 = new TopTrumps(10, 20, 30);
Card1.Text = TopTrump1.height.ToString();
}
}
}

New Topic/Question
Reply



MultiQuote





|