Esercizio concluso

This commit is contained in:
La Programmatrice Verde 2025-05-21 16:17:06 +02:00
parent edf9e69a0c
commit 248dabf958
9 changed files with 56 additions and 38 deletions

View File

@ -2,56 +2,72 @@
class Program { class Program {
static void Main(string[] args) { static void Main(string[] args) {
string[][] userEnteredValues = new string[][]
{
string[][] userEnteredValues = new string[][]
{
new string[] { "1", "2", "3"}, new string[] { "1", "2", "3"},
new string[] { "1", "two", "3"}, new string[] { "1", "two", "3"},
new string[] { "0", "1", "2"} new string[] { "0", "1", "2"}
}; };
string overallStatusMessage = ""; //string overallStatusMessage = "";
overallStatusMessage = Workflow1(userEnteredValues); //overallStatusMessage = Workflow1(userEnteredValues);
if (overallStatusMessage == "operating procedure complete") { try {
Console.WriteLine("'Workflow1' completed successfully."); Workflow1(userEnteredValues);
} }
else { catch (DivideByZeroException e) {
Console.WriteLine("An error occurred during 'Workflow1'."); Console.WriteLine("An error occurred during 'Workflow1'.");
Console.WriteLine(overallStatusMessage); Console.WriteLine(e.Message);
Console.WriteLine();
} }
static string Workflow1(string[][] userEnteredValues) { //if (overallStatusMessage == "operating procedure complete") {
string operationStatusMessage = "good"; // Console.WriteLine("'Workflow1' completed successfully.");
string processStatusMessage = ""; //}
//else {
// Console.WriteLine("An error occurred during 'Workflow1'.");
// Console.WriteLine(overallStatusMessage);
//}
static void Workflow1(string[][] userEnteredValues) {
//string operationStatusMessage = "good";
//string processStatusMessage = "";
foreach (string[] userEntries in userEnteredValues) { foreach (string[] userEntries in userEnteredValues) {
processStatusMessage = Process1(userEntries); //processStatusMessage = Process1(userEntries);
try {
if (processStatusMessage == "process complete") { Process1(userEntries);
Console.WriteLine("'Process1' completed successfully."); Console.WriteLine("'Process1' completed successfully.");
Console.WriteLine(); Console.WriteLine();
} }
else { //if (processStatusMessage == "process complete") {
// Console.WriteLine("'Process1' completed successfully.");
// Console.WriteLine();
//}
catch (FormatException e) {
Console.WriteLine("'Process1' encountered an issue, process aborted."); Console.WriteLine("'Process1' encountered an issue, process aborted.");
Console.WriteLine(processStatusMessage); Console.WriteLine(e.Message);
Console.WriteLine(); Console.WriteLine();
operationStatusMessage = processStatusMessage;
} }
//else {
// Console.WriteLine("'Process1' encountered an issue, process aborted.");
// Console.WriteLine(processStatusMessage);
// Console.WriteLine();
// operationStatusMessage = processStatusMessage;
//}
} }
if (operationStatusMessage == "good") { //if (operationStatusMessage == "good") {
operationStatusMessage = "operating procedure complete"; // operationStatusMessage = "operating procedure complete";
} //}
return operationStatusMessage; //return operationStatusMessage;
} }
static string Process1(String[] userEntries) { static void Process1(String[] userEntries) {
string processStatus = "clean"; //string processStatus = "clean";
string returnMessage = ""; //string returnMessage = "";
int valueEntered; int valueEntered;
foreach (string userValue in userEntries) { foreach (string userValue in userEntries) {
@ -64,21 +80,23 @@ class Program {
} }
} }
else { else {
returnMessage = "Invalid data. User input values must be non-zero values."; //returnMessage = "Invalid data. User input values must be non-zero values.";
processStatus = "error"; throw new DivideByZeroException("Invalid data. User input values must be non-zero values.");
//processStatus = "error";
} }
} }
else { else {
returnMessage = "Invalid data. User input values must be valid integers."; //returnMessage = "Invalid data. User input values must be valid integers.";
processStatus = "error"; throw new FormatException("Invalid data. User input values must be valid integers.");
//processStatus = "error";
} }
} }
if (processStatus == "clean") { //if (processStatus == "clean") {
returnMessage = "process complete"; // returnMessage = "process complete";
} //}
return returnMessage; //return returnMessage;
} }
} }
} }

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("es_microsoft")] [assembly: System.Reflection.AssemblyCompanyAttribute("es_microsoft")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7de842578b3a781c70401e9cda7d4a76775c93f")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+edf9e69a0ce18bcf901ab061a8edcf43c82db844")]
[assembly: System.Reflection.AssemblyProductAttribute("es_microsoft")] [assembly: System.Reflection.AssemblyProductAttribute("es_microsoft")]
[assembly: System.Reflection.AssemblyTitleAttribute("es_microsoft")] [assembly: System.Reflection.AssemblyTitleAttribute("es_microsoft")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class. // Generato dalla classe WriteCodeFragment di MSBuild.

View File

@ -1 +1 @@
56ed7301782671e005aca5beb135364494d106475fc78ab1890b2ca1c798aa82 48c28f31449a3787660df4ade160598cddc1e8aa7552882538a2c0ab6772a2ee

Binary file not shown.

Binary file not shown.