質問編集履歴

7

画像修正

2019/01/14 09:54

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -116,10 +116,10 @@
116
116
 
117
117
  ```
118
118
 
119
- クラス図のクラス名は、コード上では、Accout→BankAccount,History→Transactionsとなっています。
119
+ クラス図のクラス名は、コード上では、Accout→BankAccount,History→Transactionとなっています。
120
120
 
121
121
 
122
122
 
123
123
 
124
124
 
125
- ![イメージ説明](5c48a1ac4e82bdfa866142246cf4cb9d.png)
125
+ ![イメージ説明](5dca7be1f4f89489090db6f1bedebb77.png)

6

画像追加

2019/01/14 09:54

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -120,4 +120,6 @@
120
120
 
121
121
 
122
122
 
123
+
124
+
123
- ![UMLクラス図](51f6f3dc655928d104913cc4c3e517e6.png)
125
+ ![イメージ説明](5c48a1ac4e82bdfa866142246cf4cb9d.png)

5

画像

2019/01/14 09:47

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,11 +1,3 @@
1
- ![イメージ説明](d47099ea5537ef03b1149991746dc1bc.png)```C#
2
-
3
- List<Transaction> transactions = new List<Transaction>();
4
-
5
- transactions.Add(new Transaction(date, transactionType,depAmount, account.ToString()));
6
-
7
- ```
8
-
9
1
  コードの細かな書き方について質問です。
10
2
 
11
3
  上記List<Transaction>transactionsがあります。
@@ -123,3 +115,9 @@
123
115
  }
124
116
 
125
117
  ```
118
+
119
+ クラス図のクラス名は、コード上では、Accout→BankAccount,History→Transactionsとなっています。
120
+
121
+
122
+
123
+ ![UMLクラス図](51f6f3dc655928d104913cc4c3e517e6.png)

4

画像追加

2019/01/14 09:37

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ```C#
1
+ ![イメージ説明](d47099ea5537ef03b1149991746dc1bc.png)```C#
2
2
 
3
3
  List<Transaction> transactions = new List<Transaction>();
4
4
 

3

追加してみました…。

2019/01/14 09:30

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -51,3 +51,75 @@
51
51
  }
52
52
 
53
53
  ```
54
+
55
+ 簡単に言ってしまうと、上記if文のカッコ内は、コンボボックスの選択中のアイテム(口座タイプ、アカウントナンバー)と、ローカル変数であるaccount.ToString()(口座タイプ、アカウントナンバー)の照合です。
56
+
57
+
58
+
59
+ しかし、もっと言うと、アカウントナンバー自体は、BankAccountという親クラスにプロパティがあります。
60
+
61
+ var account = Combobox1.SelectedItem as BankAccount;このようにして、asオペレーターでBankAccountにあるプロパティのようにふるまわせています。
62
+
63
+ Transactionクラスはあくまで以下のプロパティしかもっておらず、BankAccountクラスとはアソシエーションの関係にあります…。
64
+
65
+
66
+
67
+ よって、BankAccount内のAccountNumberプロパティを直接照合させて使うこともできるはずなのですが(そのほうがややこしくなさそうです)、object.AccountNumberとするためには、オブジェクトが必要になりそうです。
68
+
69
+
70
+
71
+ ```C#
72
+
73
+ namespace practice
74
+
75
+ {
76
+
77
+ [Serializable]
78
+
79
+ class Transaction
80
+
81
+ {
82
+
83
+ internal bool AccountNumber;
84
+
85
+ public double Amount { get; set; }
86
+
87
+ public DateTime Date { get; set; }
88
+
89
+ public string TransactionType { get; set; }
90
+
91
+ public List<BankAccount> BankAccounts { get; private set; } = new List<BankAccount>();
92
+
93
+
94
+
95
+
96
+
97
+ // Constructors
98
+
99
+ public Transaction(DateTime date, string transactionType, double amount, string s)
100
+
101
+ {
102
+
103
+ Amount = amount;
104
+
105
+ Date = DateTime.Now;
106
+
107
+ TransactionType =transactionType ;
108
+
109
+
110
+
111
+ }
112
+
113
+
114
+
115
+ // Methods
116
+
117
+ public override string ToString()
118
+
119
+ {
120
+
121
+ return $"\n{Date} {TransactionType}: {Amount}SEK ";
122
+
123
+ }
124
+
125
+ ```

2

加筆修正

2019/01/14 08:43

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- 質問1.var transaction account.ToString()を抽出したいです。(Containsメソッドでいいのでしょうか。それとも、FirstOrDefaultでしょうか。)
19
+ 質問1.var transaction などの変数をつくり、account.ToString()を抽出したいです。(使用メソッドは、Containsでいいのでしょうか。それとも、FirstOrDefaultでしょうか。)
20
20
 
21
21
 
22
22
 

1

加筆修正

2019/01/13 09:59

投稿

irm
irm

スコア25

test CHANGED
File without changes
test CHANGED
@@ -16,6 +16,10 @@
16
16
 
17
17
 
18
18
 
19
+ 質問1.var transaction でaccount.ToString()を抽出したいです。(Containsメソッドでいいのでしょうか。それとも、FirstOrDefaultでしょうか。)
20
+
21
+
22
+
19
23
  その後、
20
24
 
21
25
  1. コンボボックス(ドロップダウンメニューのようなもの)の選択されたitem
@@ -26,7 +30,7 @@
26
30
 
27
31
 
28
32
 
29
- そこで質問ですが、下記コードの日本語部分に該当するコードの書き方が知りたいです。
33
+ そこで質問ですが、下記コードの日本語部分に該当するコードの書き方が知りたいです。
30
34
 
31
35
 
32
36