Skip to content

Commit 10a0a5a

Browse files
committed
Users input check moved to a new method
1 parent f3eac30 commit 10a0a5a

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

CacheSimulator/MainWindow.xaml.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,8 @@ private async void StartSimulation(object sender, RoutedEventArgs e)
5454
{
5555
logNumberOfWrites = 0;
5656

57-
if (traceFileFullPaths == null)
58-
{
59-
MessageBox.Show("Please insert the trace file first.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
60-
return;
61-
}
62-
else if (ramFileFullPath == null)
63-
{
64-
MessageBox.Show("Please insert the RAM file first.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
65-
return;
66-
}
67-
else if (cacheSize.Text == "" || cacheLineSize.Text == "")
57+
if (!SimulationStartCheck())
6858
{
69-
MessageBox.Show("Please fill out all of the cache parameters with values.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
7059
return;
7160
}
7261

@@ -206,6 +195,27 @@ private async void StartSimulation(object sender, RoutedEventArgs e)
206195
}
207196

208197

198+
private bool SimulationStartCheck()
199+
{
200+
if (traceFileFullPaths == null)
201+
{
202+
MessageBox.Show("Please insert the trace file first.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
203+
return false;
204+
}
205+
else if (ramFileFullPath == null)
206+
{
207+
MessageBox.Show("Please insert the RAM file first.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
208+
return false;
209+
}
210+
else if (cacheSize.Text == "" || cacheLineSize.Text == "")
211+
{
212+
MessageBox.Show("Please fill out all of the cache parameters with values.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
213+
return false;
214+
}
215+
216+
return true;
217+
}
218+
209219
private CacheConfigurationBuilder GetCacheConfigBuilder()
210220
{
211221
var cacheConfigBuilder = new CacheConfigurationBuilder();

0 commit comments

Comments
 (0)