+ 2
C# dancerpoints
help me code this one please
16 Réponses
+ 34
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b) {
string name = a.name +" "+"&"+" "+ b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
}
}
i just solve it
+ 18
class DancerPoints
{
public string name;
public int points;
public DancerPoints(string name, int points)
{
this.name = name;
this.points = points;
}
public static DancerPoints operator+ (DancerPoints a, DancerPoints b) {
string name = a.name + " " + "&" + " " + b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
I solved it just now😭😭🤯
+ 1
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b) {
string name = a.name +" "+"&"+" "+ b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
}
}
+ 1
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 dp1, DancerPoints dp2)
{
return new DancerPoints(dp1.name+" "+"&"+" "+dp2.name, dp1.points + dp2.points);
}
}
+ 1
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b) {
string name = a.name +" "+"&"+" "+ b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
}
}
0
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 dp1, DancerPoints dp2) {
string name = dp1.name +" "+"&"+" "+ dp2.name ;
int points = dp1.points + dp2.points ;
return new DancerPoints (name, points);
}
}
}
0
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b)
{
string name = a.name + " " + "&" + " " + b.name;
int points = a.points + b.points;
DancerPoints total = new DancerPoints(name, points);
return total;
}
}
0
public static DancerPoints operator + (DancerPoints a, DancerPoints b)
=> new DancerPoints(a.name + " & " + b.name, a.points + b.points);
0
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b) {
string name = a.name +" "+"&"+" "+ b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
}
}
WOW AMAZING
0
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
class DancerPoints
{
public string name;
public int points;
public DancerPoints(string name, int points)
{
this.name = name;
this.points = points;
}
public static DancerPoints operator+(DancerPoints d1,DancerPoints d2){
string s = d1.name
+" & "+ d2.name;
int totalpoints=d1.points+d2.points;
DancerPoints total =new DancerPoints(s,totalpoints);
return total;
}
}
}
0
// my solution
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
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 a, DancerPoints b) {
string name = a.name +" "+"&"+" "+ b.name ;
int points = a.points + b.points ;
DancerPoints total = new DancerPoints (name, points);
return total ;
}
}
}
0
I don't understand concept at all 💔💔
0
using System;
public class Program
{
public static void Main(string[] args)
{
Console.WritLine("My first C# Code Coach!");
}
}
0
Theres a bug on this one.
"DancerPoints total = new DancerPoints (name, points);" is what is "correct". Sololearn is looking for this: "DancerPoints total = new DancerPoints (nam, points);" - notice nam instead of name.
- 1
Dance
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().
Sample Input
Dave
8
Jessica
7
Sample Output
Dave & Jessica
15
- 5
using System;
using System.Collections.Generic;
namespace Code_Coach_Challenge
{
class Program
{
static void Main(string[] args)
{
string name1 = Console.ReadLine();
int points1 = Convert.ToInt32(Console.ReadLine());
string name2 = Console.ReadLine();
int points2 = Convert.ToInt32(Console.ReadLine());
DancerPoints dancer1 = new DancerPoints(name1, points1);
DancerPoints dancer2 = new DancerPoints(name2, points2);
DancerPoints total = dancer1 + dancer2;
Console.WriteLine(total.name);
Console.WriteLine(total.points);
}
}
class DancerPoints
{
public string name;
public int points;
public DancerPoints(string name, int points)
{
this.name = name;
this.points = points;
}
//overload the + operator
}
}