accessing windows forms textbox properties
i have a class that outputs text to the console, i want to output the same text to a textbox, however the console method is in a different class, i have been raeding Deitel C# how to program and see various ways to achieve this but im not sure which way is best. here are the classes involved in outputing the text
Code:
using System;
using System.Collections;
namespace TrafficControlSim
{
public class TrafficQueue
{
private Queue vehicleQueue;//fifo object
// constructor - one integer input
public TrafficQueue(int maximumQueueSize)
{
vehicleQueue = new Queue(maximumQueueSize);
}
public void Arrive(Vehicle arrival)
{
vehicleQueue.Enqueue(arrival);//add vehicle to queue
}
public int TrafficQueueSize()
{
return vehicleQueue.Count;
}
public Vehicle Depart()
{
Vehicle aVehicle;
if (vehicleQueue.Count>0)
{
aVehicle=(Vehicle)vehicleQueue.Dequeue();
vehicleQueue.TrimToSize();
return (aVehicle);
}
else
return null;
}
public int TrafficInQueue()
{
if (vehicleQueue.Count>0)
foreach(Vehicle aVehicle in vehicleQueue)
aVehicle.ShowType();/* i want to send this text to the textbox in Form1 class */
else
Console.WriteLine("Traffic Queue is Empty.");
return vehicleQueue.Count;
}
}
}
Code:
using System;
namespace TrafficControlSim
{
public class Vehicle
{
private string registrationNumber;
private string vehicleType;
public Vehicle()
{
registrationNumber="TBD";
vehicleType="TBC";
}
public virtual void ShowDetails()
{
Console.WriteLine("Vehicle is a "+vehicleType);
Console.WriteLine("Registration number is "+registrationNumber);
}
public void SetRegistrationNumber(string number)
{
registrationNumber=number;
}
public void SetVehicleType(string type)
{
vehicleType=type;
}
public string GetRegistrationNumber()
{
return registrationNumber;
}
public string GetVehicleType()
{
return vehicleType;
}
public string ShowType()
{
return vehicleType+" ";
}
}/* end class */
}/* end namespace */
the Form1 class is rather large which inherits from System.Windows.Forms.Form this class has the textboxs i want to display . I have been working on this for a few days now and am getting quite frustrated due to my lack on knowledge around OOP
thanks in advance