• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguicwindows翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

練習用です。いろんなものがごちゃまぜです。


コミットメタ情報

リビジョン392 (tree)
日時2018-05-10 16:40:46
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- Calc/Calc/Form1.vb (revision 391)
+++ Calc/Calc/Form1.vb (revision 392)
@@ -6,8 +6,8 @@
66 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click, ButtonPlus.Click, Button9.Click, Button8.Click, Button7.Click, Button6.Click, Button5.Click, Button4.Click, Button3.Click, Button2.Click, Button14.Click, Button13.Click, Button12.Click, Button11.Click, Button0.Click
77 Dim t = DirectCast(sender, Button).Text(0)
88 r.add(t)
9- TextBox1.Text = r.LastValue()
10- Label1.Text = r.Last
9+ TextBox1.Text = r.value()
10+ Label1.Text = r.expression
1111 ListBox1.DataSource = Nothing
1212 ListBox1.DataSource = r.history
1313 End Sub
--- Calc/Calc/calcModel.vb (revision 391)
+++ Calc/Calc/calcModel.vb (revision 392)
@@ -1,37 +1,38 @@
11 Public Class calcModel
22
33
4- Public history As New List(Of String)
4+ Public Property history As New List(Of String)
55
6- Public Last As String
6+ Public Property expression As String
77
8- Private isNew As Boolean = False
8+ Private isTerminal As Boolean = False
99
1010 Private e As New evaluator
1111
12- Public Function LastValue() As String
13- Return e.ValueStr(Last)
12+ Public Function value() As String
13+ Return e.ValueStr(expression)
1414 End Function
1515
1616
1717 Public Sub add(ByVal c As Char)
1818
19- If isNew Then
20- isNew = False
19+ If isTerminal Then
20+ isTerminal = False
2121
2222 If Not ("0"c <= c AndAlso c <= "9"c) Then
23- Last = e.ValueStr(Last)
23+ '数字以外が入力された場合直前の計算結果を引き継ぐ
24+ expression = value()
2425 Else
25- Last = ""
26+ expression = String.Empty
2627 End If
2728
2829 End If
2930
30- Last &= c
31+ expression &= c
3132
3233 If c = "="c Then
33- isNew = True
34- history.Add(Last + LastValue())
34+ isTerminal = True
35+ history.Add(expression + value())
3536 End If
3637
3738 End Sub