Javaの講義、試験が「自作関数を作り記述しなさい」って問題だったから
「ズン」「ドコ」のいずれかをランダムで出力し続けて「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら「キ・ヨ・シ!」って出力した後終了って関数作ったら満点で単位貰ってた
そこで、PowerPoint VBAで作ってみた。
Sub addSlide(text As String, Optional size As Integer = 360)
With ActivePresentation.Slides
Dim slide As slide
Set slide = .addSlide( _
Index:=(.count + 1), _
pCustomLayout:=.Parent.SlideMaster.CustomLayouts(7) _
)
With slide
Dim shape As shape
Set shape = .Shapes.AddShape( _
Type:=msoShapeRectangle, _
Left:=0, _
Top:=0, _
Width:=960, _
Height:=540 _
)
With shape
.TextEffect.FontSize = size
.TextFrame.TextRange.text = text
End With
End With
End With
End Sub
Sub Zundoko()
Do While True
If Rnd < 0.5 Then
addSlide "ズン"
Else
addSlide "ドコ"
End If
With ActivePresentation.Slides
Dim zd As String
zd = ""
For i = 4 To 0 Step -1
If .count - i > 0 Then
If .Item(.count - i).Shapes.count > 0 Then
zd = zd + .Item(.count - i).Shapes.Item(1).TextFrame.TextRange.text
End If
End If
Next
If zd = "ズンズンズンズンドコ" Then
Exit Do
End If
End With
Loop
addSlide "キ・ヨ・シ!", 144
End Sub
With ActivePresentation.Slides
Dim slide As slide
Set slide = .addSlide( _
Index:=(.count + 1), _
pCustomLayout:=.Parent.SlideMaster.CustomLayouts(7) _
)
With slide
Dim shape As shape
Set shape = .Shapes.AddShape( _
Type:=msoShapeRectangle, _
Left:=0, _
Top:=0, _
Width:=960, _
Height:=540 _
)
With shape
.TextEffect.FontSize = size
.TextFrame.TextRange.text = text
End With
End With
End With
End Sub
Sub Zundoko()
Do While True
If Rnd < 0.5 Then
addSlide "ズン"
Else
addSlide "ドコ"
End If
With ActivePresentation.Slides
Dim zd As String
zd = ""
For i = 4 To 0 Step -1
If .count - i > 0 Then
If .Item(.count - i).Shapes.count > 0 Then
zd = zd + .Item(.count - i).Shapes.Item(1).TextFrame.TextRange.text
End If
End If
Next
If zd = "ズンズンズンズンドコ" Then
Exit Do
End If
End With
Loop
addSlide "キ・ヨ・シ!", 144
End Sub