Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
8.2.1 Combining interfaces<br />
New interaces can be created by combining two of more base interfaces. For example,<br />
based on the previous example, we can add another interface which defines a<br />
calcDifference() method:<br />
interface NewCircuit<br />
{<br />
double r1 { <strong>set</strong>; get;}<br />
double r2 { <strong>set</strong>; get;}<br />
double calcParallel();<br />
double calcSeries();<br />
}<br />
interface NewCircuit2<br />
{<br />
double calcDifference();<br />
}<br />
These interfaces can be merged with:<br />
interface NewCircuitTotal : NewCircuit, NewCircuit2<br />
{}<br />
Then the class is derived with:<br />
public class Circuit: NewCircuitTotal<br />
{<br />
private double res1, res2;<br />
duction <strong>to</strong> .NET<br />
<strong>Intro</strong><br />
public double r1<br />
{<br />
<strong>set</strong> { res1=value;}<br />
get { return res1; }<br />
}<br />
public double r2<br />
{<br />
<strong>set</strong> { res2=value;}<br />
get { return res2; }<br />
}<br />
public void Setr2(double r)<br />
{<br />
r2=r;<br />
}<br />
public double calcParallel()<br />
{<br />
return((r1*r2)/(r1+r2));<br />
}<br />
public double calcSeries()<br />
{<br />
return(r1+r2);<br />
}<br />
public double calcDifference()<br />
{<br />
return(r1-r2);<br />
Agilent .NET Course: More Objects 6