hello... i have an issue and need help... i will calculate two circuits with two resistors, parallel or serie... for this i have created an abstract class KretsDel, which has two protected fields(resistors), and abstract property, Total and a constructor.
further i have created two classes Parallel and Serie, which contains the propertyTotal which returns the result of resistors connections.
further i have created a class Krets with a field List<KretsDel> and two methoder for calculation of serie or parallel coupling for each element in List<KretsDel>... but i get errors...
the following is my codes:
- class Program
- {
- static void Main(string[] args)
- {
- Krets k = new Krets();
- }
- }
- abstract class KretsDel
- {
- protected float R1, R2;
- public abstract float Total
- {
- get;
- set;
- }
- public KretsDel(int r1,int r2)
- {
- this.R1 = r1;
- this.R2 = r2;
- }
- }
- class Parallel : KretsDel
- {
- override public float Total
- {
- set
- {
- this.R1 = value;
- this.R2 = value;
- }
- get { return parallel(this.R1, this.R2); }
- }
- public float parallel(float r1, float r2)
- {
- float R = r1 *r2 / (r1 + r2);
- return R;
- }
- }
- class Serie : KretsDel
- {
- override public float Total
- {
- set
- {
- this.R1 = value;
- this.R2 = value;
- }
- get { return serie(this.R1, this.R2); }
- }
- public float serie(float r1, float r2)
- {
- float R =r1 + r2;
- return R;
- }
- }
- public class Krets
- {
- static Parallel parallel = new Parallel();
- static Serie serie = new Serie();
- List<KretsDel> lkd = new List<KretsDel>() { parallel, serie };
- foreach(var k in lkd)
- k.Total;
- public float ser(float r1, float r2)
- {
- float R = r1 + r2;
- return R;
- }
- public float para(float r1, float r2)
- {
- float R = r1 * r2 / (r1 + r2);
- return R;
- }
- }
appreciate any help... kind regards