R3B3L 0 Newbie Poster

I always get stuck in this type of assignments, I don't know how to pass string values to a function...

Here's the full program:

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

namespace Test_1_1
{
    abstract class RealNumber
    {
        protected float real;
        public abstract float Real { get; }
    }


    class ComplexNumber : RealNumber
    {
        private float imaginary;

        public ComplexNumber()
        {
            real = 0.0f;
            imaginary = 0.0f;
        }

        public ComplexNumber(float realValue, float imaginaryValue)
        {
            real = realValue;
            imaginary = imaginaryValue;
        }

        public ComplexNumber(string value)
        {
        }

        public override float Real 
        { 
            get
            {
                return real;
            }
        }

        public float Imginary
        {
            get
            {
                return imaginary;
            }
        }

        public static ComplexNumber operator +(ComplexNumber complex1, ComplexNumber complex2)
        {
            ComplexNumber result = new ComplexNumber();

            result.real = complex1.real + complex2.real;
            result.imaginary = complex1.imaginary + complex2.imaginary;

            return result;
        }

        public static ComplexNumber operator -(ComplexNumber complex1, ComplexNumber complex2)
        {
            ComplexNumber result = new ComplexNumber();

            result.real = complex1.real - complex2.real;
            result.imaginary = complex1.imaginary - complex2.imaginary;

            return result;
        }

        public static ComplexNumber operator *(ComplexNumber complex1, ComplexNumber complex2)
        {
            ComplexNumber result = new ComplexNumber();

            result.real = complex1.real * complex2.real;
            result.imaginary = complex1.imaginary * complex2.imaginary;

            return result;
        }

        public override string ToString()
        {
            return "( " + real + ( imaginary < 0 ? " - " + ( imaginary * -1 ) : " + "  + imaginary ) + "i )"; 
        }
    }

    class ComplexNumberCalculator
    {
        public ComplexNumberCalculator()
        {
 
        }

        public ComplexNumber Calculate(string value)
        {
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            ComplexNumber a = new ComplexNumber("2 + 4i");
            ComplexNumber b = new ComplexNumber("5 + 3i");

            Console.WriteLine(a * b);

            ComplexNumberCalculator cc = new ComplexNumberCalculator();

            Console.WriteLine(cc.Calculate("1+3i + 2+4i * 5+3i"));
            Console.WriteLine(cc.Calculate("2-2i * 2.2+7.8i * 7.1+2i + 4.5+1.1i"));
            Console.WriteLine(cc.Calculate("1-1i - 4.7+3i + 11+15.1i - 4.5+1.1i + 5-7i"));

            Console.Read();
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.