-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdancer points.cs
86 lines (64 loc) · 1.87 KB
/
dancer points.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
// just posted questinon
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;// you can change name and point to something else :D
public int points;
public DancerPoints(string name, int points)
{
this.name = name;
this.points = points;
}
//overload the + operator
public static DancerPoints operator+ (DancerPoints n, DancerPoints p)
{
string name = n.name + " & " + p.name;
int points = n.points + p.points;
DancerPoints res = new DancerPoints(name, points);
return res;
//DancerPoints( name1 + "&" + name2 = name , points1 + points2 = points);
}
}
}
/*
public static DancerPoints operator+ (DancerPoints a, DancerPoints b)
{
string name = a.name + "&" + b.name;
int points = a.points + b.points;
DancerPoints res = new DancerPoints(name, points)
return res;
}
public static Box operator+ (Box b, Box c)
{
Box box = new Box();
box.length = b.length + c.length;
box.breadth = b.breadth + c.breadth;
return box;
}
input
Dave
8
Jessica
7
output
Dave & Jessica
15
*/