define a class called dc with two data members: cname and duration. Include relevant constructors & operator methods to perform these operations:
dc c1= new dc("BSC",2);
dc c2= new dc("BMS",2);
if (c1>c2)
System.Console.WriteLine("c1>c2");
else if(c1==c2)
System.Console.WriteLine("c1=c2");
else
System.Console.WriteLine("c2>c1");
1
Expert's answer
2012-10-05T08:07:21-0400
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions;
namespace Occurrences_of_the_second_string_in_the_fisrt { class dc { public string cname; public int duration;
public dc() { }
public dc(string cname, int duration) { // TODO: Complete member initialization this.cname = cname; this.duration = duration; }
} class Program { static void Main(string[] args) { dc c1 = new dc("BSC", 2); dc c2 = new dc("BMS", 2); if (c1.duration>c2.duration) { System.Console.WriteLine("c1>c2"); }else if(c1==c2) { System.Console.WriteLine("c1=c2"); }else{ System.Console.WriteLine("c2>c1"); } } } }
Comments
Leave a comment