0

ما حل هذه المسألة؟؟؟

In a ballroom dancing competition, each dancer from a pair is evaluated separately, and then their points are summed up to get the total pair score. The program you are given takes the names and the points of each dancer as input and creates a DancerPoints objects for each dancer, using the taken name and score values as parameters for constructors. Complete the given class, using overload + operator to return an new object where the names of dancers are in one string (see sample output) and the score is equal to the sum of their points. The declaration of that object and the output of its points are already written in Main().

22nd Jul 2022, 3:18 PM
Zina Shekh Alzoor
Zina Shekh Alzoor - avatar
2 Answers
+ 2
// Hope this code helps you https://code.sololearn.com/cX1Oge1hP1CC public static DancerPoints operator+ (DancerPoints dp1, DancerPoints dp2) { string name = dp1.name + " " + dp2.name; int points = dp1.points + dp2.points; DancerPoints res= new DancerPoints (name , points); return res; }
22nd Jul 2022, 5:35 PM
SoloProg
SoloProg - avatar
0
class DancerPoints { public string name; public int points; public DancerPoints(string name, int points) { this.name = name; this.points = points; } //overload the + operator public static DancerPoints operator+ (DancerPoints name ,DancerPoints points ) { DancerPoints res=new DancerPoints (name ,points ); return res; } }
22nd Jul 2022, 3:19 PM
Zina Shekh Alzoor
Zina Shekh Alzoor - avatar