質問編集履歴

2

ソース修正

2018/12/27 04:51

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -46,156 +46,156 @@
46
46
 
47
47
  c#
48
48
 
49
+
50
+
51
+ namespace renshu
52
+
53
+ {
54
+
55
+ /// <summary>
56
+
57
+ /// Interaction logic for MainWindow.xaml
58
+
59
+ /// </summary>
60
+
61
+ public partial class MainWindow : Window
62
+
63
+ {
64
+
65
+ public MainWindow()
66
+
67
+ {
68
+
69
+ InitializeComponent();
70
+
71
+ }
72
+
73
+
74
+
75
+ List<Person> listOfPerson = new List<Person>();
76
+
77
+
78
+
79
+ private void BtnAdd_Click(object sender, RoutedEventArgs e)
80
+
81
+ {
82
+
83
+ string firstName = TxtFirstName.Text;
84
+
85
+ string lastName = TxtLastName.Text;
86
+
87
+ string fullName = TxtFirstName.Text + " " + TxtLastName.Text;
88
+
89
+ string inputAge = TxtAge.Text;
90
+
91
+ int age = int.Parse(inputAge);
92
+
93
+
94
+
95
+
96
+
97
+ if (firstName != "" || lastName != "")
98
+
99
+ {
100
+
101
+ NameList.Items.Add(fullName + " : ");
102
+
103
+ listOfPerson.Add(fullName + inputAge); //ここは修正が必要です。
104
+
105
+ }
106
+
107
+ }
108
+
109
+
110
+
111
+ private void BtnSort_Click(object sender, RoutedEventArgs e)
112
+
113
+ {
114
+
115
+ //ここでlistOfPersonのリストをソートしたかったのですが、OrderByを使う関係でクラスを作らねばなりませんでした。
116
+
117
+ }
118
+
119
+
120
+
121
+ private void BtnDivide_Click(object sender, RoutedEventArgs e)
122
+
123
+ {
124
+
125
+ int nrOfCookies = int.Parse(TxtTotalCandies.Text);
126
+
127
+ int c = listOfPerson.Count;
128
+
129
+ int pcsPerPerson = nrOfCookies / c;
130
+
131
+ int remainder = nrOfCookies % c;
132
+
133
+
134
+
135
+ for (int i = 0; i < c; i++)
136
+
137
+ {
138
+
139
+ NameList.Items[i] += " " + " もらえるクッキーは"+(pcsPerPerson).ToString() + " 個です。";
140
+
141
+ }
142
+
143
+
144
+
145
+ if (remainder != 0)
146
+
147
+ {
148
+
149
+ for (int i = 0; i < remainder; i++)
150
+
151
+ {
152
+
153
+ NameList.Items[i] += " " + "+1" + " 1個のおまけもつきます。";
154
+
155
+ }
156
+
157
+ }
158
+
159
+ }
160
+
161
+
162
+
163
+ private void BtnClear_Click(object sender, RoutedEventArgs e)
164
+
165
+ {
166
+
167
+ string firstName = TxtFirstName.Text;
168
+
169
+ string lastName = TxtLastName.Text;
170
+
171
+ NameList.Items.Clear();
172
+
173
+ listOfPerson.Clear();
174
+
175
+ TxtFirstName.Clear();
176
+
177
+ TxtLastName.Clear();
178
+
179
+ TxtAge.Clear();
180
+
181
+ TxtTotalCookies.Clear();
182
+
183
+
184
+
185
+ }
186
+
187
+
188
+
189
+
190
+
191
+ }
192
+
193
+ }
194
+
195
+
196
+
49
197
  ```
50
198
 
51
- namespace renshu
52
-
53
- {
54
-
55
- /// <summary>
56
-
57
- /// Interaction logic for MainWindow.xaml
58
-
59
- /// </summary>
60
-
61
- public partial class MainWindow : Window
62
-
63
- {
64
-
65
- public MainWindow()
66
-
67
- {
68
-
69
- InitializeComponent();
70
-
71
- }
72
-
73
-
74
-
75
- List<Person> listOfPerson = new List<Person>();
76
-
77
-
78
-
79
- private void BtnAdd_Click(object sender, RoutedEventArgs e)
80
-
81
- {
82
-
83
- string firstName = TxtFirstName.Text;
84
-
85
- string lastName = TxtLastName.Text;
86
-
87
- string fullName = TxtFirstName.Text + " " + TxtLastName.Text;
88
-
89
- string inputAge = TxtAge.Text;
90
-
91
- int age = int.Parse(inputAge);
92
-
93
-
94
-
95
-
96
-
97
- if (firstName != "" || lastName != "")
98
-
99
- {
100
-
101
- NameList.Items.Add(fullName + " : ");
102
-
103
- listOfPerson.Add(fullName + inputAge); //ここは修正が必要です。
104
-
105
- }
106
-
107
- }
108
-
109
-
110
-
111
- private void BtnSort_Click(object sender, RoutedEventArgs e)
112
-
113
- {
114
-
115
- //ここでlistOfPersonのリストをソートしたかったのですが、OrderByを使う関係でクラスを作らねばなりませんでした。
116
-
117
- }
118
-
119
-
120
-
121
- private void BtnDivide_Click(object sender, RoutedEventArgs e)
122
-
123
- {
124
-
125
- int nrOfCookies = int.Parse(TxtTotalCandies.Text);
126
-
127
- int c = listOfPerson.Count;
128
-
129
- int pcsPerPerson = nrOfCookies / c;
130
-
131
- int remainder = nrOfCookies % c;
132
-
133
-
134
-
135
- for (int i = 0; i < c; i++)
136
-
137
- {
138
-
139
- NameList.Items[i] += " " + " もらえるクッキーは"+(pcsPerPerson).ToString() + " 個です。";
140
-
141
- }
142
-
143
-
144
-
145
- if (remainder != 0)
146
-
147
- {
148
-
149
- for (int i = 0; i < remainder; i++)
150
-
151
- {
152
-
153
- NameList.Items[i] += " " + "+1" + " 1個のおまけもつきます。";
154
-
155
- }
156
-
157
- }
158
-
159
- }
160
-
161
-
162
-
163
- private void BtnClear_Click(object sender, RoutedEventArgs e)
164
-
165
- {
166
-
167
- string firstName = TxtFirstName.Text;
168
-
169
- string lastName = TxtLastName.Text;
170
-
171
- NameList.Items.Clear();
172
-
173
- listOfPerson.Clear();
174
-
175
- TxtFirstName.Clear();
176
-
177
- TxtLastName.Clear();
178
-
179
- TxtAge.Clear();
180
-
181
- TxtTotalCookies.Clear();
182
-
183
-
184
-
185
- }
186
-
187
-
188
-
189
-
190
-
191
- }
192
-
193
- }
194
-
195
-
196
-
197
- ```
198
-
199
199
 
200
200
 
201
201
 

1

ソースを見やすく囲いました

2018/12/27 04:51

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -42,8 +42,12 @@
42
42
 
43
43
 
44
44
 
45
+
46
+
45
47
  c#
46
48
 
49
+ ```
50
+
47
51
  namespace renshu
48
52
 
49
53
  {
@@ -96,7 +100,7 @@
96
100
 
97
101
  NameList.Items.Add(fullName + " : ");
98
102
 
99
- listOfPerson.Add(fullName , inputAge);
103
+ listOfPerson.Add(fullName + inputAge); //ここは修正が必要です。
100
104
 
101
105
  }
102
106
 
@@ -190,6 +194,8 @@
190
194
 
191
195
 
192
196
 
197
+ ```
198
+
193
199
 
194
200
 
195
201