- 8
- 2
- CPU
- Intel core i5 - 4590
- Scheda Madre
- ASUS H81I-PLUS
- HDD
- SSD 120/128 GB SATA
- RAM
- DDR3-1600 DIMM 8GB
- GPU
- KFA Geforce GTX 1060 OC
- Audio
- Logitech 5.1 Sound system 75W
- Monitor
- 24"(60.9 cm) Full HD monitor gaming
- Periferiche
- Wireless keyboard with touchpad + Logitech G29 steering wheel/pedal set
- Net
- Fastweb ADSL2+ 20Mb
- OS
- Windows 10
Ciao a tutti :)
Mi sono appena iscritto e questa è la mia prima discussione quindi spero di non stare violando qualche regolamento di cui non sono a conoscenza. Per motivi lavorativi sto attualmente studiando il linguaggio C#. Per questo volevo semplicemente chiedervi cosa ne pensate del mio primo programma C#. L'ho scritto in un paio di giorni e questo linguaggio è completamente nuovo per me, quindi vi chiedo scusa se è poco ottimizzato o non molto comprensibile a livello di logica, purtroppo sono ancora abituato al mio amato C++ e alla sua logica "sequenziale" mentre in C#, come in Java, si fa molto riferimento ai concetti di 'classe' e di 'metodo', concetti nuovi per me. Con questa discussione volevo semplicemente chiedervi consigli, magari potete aiutarmi ad ambientarmi con questa nuova logica o magari avete consigli direttamente legati alla programmazione del mio progetto. Grazie a tutti in anticipo, chiedo scusa se mi sono dilungato :)
Di seguito il codice di cui vi ho parlato, altro non è che una calcolatrice ma con alcune funzioni in più, attualmente sto sviluppando la modalità "segreta" sviluppatore, poi provvederò a convertire le variabili in tipo 'decimal' per una maggiore precisione per certe operazioni:
Mi sono appena iscritto e questa è la mia prima discussione quindi spero di non stare violando qualche regolamento di cui non sono a conoscenza. Per motivi lavorativi sto attualmente studiando il linguaggio C#. Per questo volevo semplicemente chiedervi cosa ne pensate del mio primo programma C#. L'ho scritto in un paio di giorni e questo linguaggio è completamente nuovo per me, quindi vi chiedo scusa se è poco ottimizzato o non molto comprensibile a livello di logica, purtroppo sono ancora abituato al mio amato C++ e alla sua logica "sequenziale" mentre in C#, come in Java, si fa molto riferimento ai concetti di 'classe' e di 'metodo', concetti nuovi per me. Con questa discussione volevo semplicemente chiedervi consigli, magari potete aiutarmi ad ambientarmi con questa nuova logica o magari avete consigli direttamente legati alla programmazione del mio progetto. Grazie a tutti in anticipo, chiedo scusa se mi sono dilungato :)
Di seguito il codice di cui vi ho parlato, altro non è che una calcolatrice ma con alcune funzioni in più, attualmente sto sviluppando la modalità "segreta" sviluppatore, poi provvederò a convertire le variabili in tipo 'decimal' per una maggiore precisione per certe operazioni:
C#:
#region USING
using System;
using System.Collections;
using System.Windows;
using System.Timers;
using System.Threading;
/* *LIBRERIE EXTRA*
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;/using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions; */
#endregion
#region NAMESPACE
namespace ECALC
{
#region CLASS
class Program
{
#region WARNINGS/ERRORS
/* *WARNING TEST*
#pragma warning disable CS1030
#warning <WARNING> */
#pragma warning disable IDE0060
#pragma warning disable IDE0059
#pragma warning disable CS0219
#endregion
#region METODI
/* // *METODO TIMER - TEST*
// private static readonly System.Timers.Timer Timer = new System.Timers.Timer();
// private static System.Timers.Timer aTimer;
private static void Elapsed(Object source, ElapsedEventArgs e)
{
Console.WriteLine("");
}
private static void SetTimer()
{
aTimer = new System.Timers.Timer(5000)
{
Enabled = true
};
}*/
// *METODO CONTROLLO CARATTERI*
public static int VerificaNumero(string valoreDaControllare)
{
int ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = Int32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.Clear();
Messaggio();
Console.WriteLine("\n\n");
Menu();
Console.Write("ENTER A NEW NUMERICAL CHARACTER: ");
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
/*do {
try {
numero = int.Parse(Console.ReadLine());
return true;
} catch (FormatException) {
Console.WriteLine("ERROR! NOT SUPPORTED CHARACTER TYPE. ");
return false;
}
} while (a != 1); */
}
// *SECONDO METODO CONTROLLO CARATTERE*
public static int VerificaNumero2(string valoreDaControllare)
{
int ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = Int32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.WriteLine("\n");
Messaggio();
Messaggio2();
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
/*do {
try {
numero = int.Parse(Console.ReadLine());
return true;
} catch (FormatException) {
Console.WriteLine("ERROR! NOT SUPPORTED CHARACTER TYPE. ");
return false;
}
} while (a != 1); */
}
// *TERZO METODO CONTROLLO CARATTERE*
public static uint VerificaNumero3(string valoreDaControllare)
{
uint ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = UInt32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.WriteLine("\n");
Messaggio();
Messaggio2();
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
/*do {
try {
numero = int.Parse(Console.ReadLine());
return true;
} catch (FormatException) {
Console.WriteLine("ERROR! NOT SUPPORTED CHARACTER TYPE. ");
return false;
}
} while (a != 1); */
}
// *METODO MENU*
public static void Menu()
{
Console.WriteLine("OPTIONS: \n\n");
Console.WriteLine("1. SUM; \n");
Console.WriteLine("2. SUBTRACTION; \n");
Console.WriteLine("3. MULTIPLICATION; \n");
Console.WriteLine("4. DIVISION; \n");
Console.WriteLine("5. SQUARE ROUND; \n");
Console.WriteLine("6. EXPONENTIATION; \n");
Console.WriteLine("7. FACTORIAL; \n");
Console.WriteLine("8. TETRATION; \n");
Console.WriteLine("9. CUBIC ROOT; \n");
Console.WriteLine("10. PERCENTAGE; \n");
Console.WriteLine("0. EXIT; \n\n");
}
// *METODO MESSAGGIO*
public static void Messaggio()
{
Console.WriteLine("ERROR! NOT SUPPORTED CHARACTER TYPE. ");
}
// *METODO MESSAGGIO 2*
public static void Messaggio2()
{
Console.Write("ENTER THE REQUIRED DATA: ");
}
/* *TEST METODO*
static public void soloNumeri(KeyPressEventArgs ev) {
if (!IsNumeric(ev.KeyChar.ToString()) & amp; & (((int)ev.KeyChar) != 8))
ev.Handled = true;
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) {
soloNumeri(e);
}
*/
// *METODO CONTROLLO SECRET_CODE*
public static int VERIFICA_SECRET_CODE(string valoreDaControllare)
{
int ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = Int32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.WriteLine("\n");
Messaggio_SC();
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
}
// *METODO MESSAGGIO SC*
public static void Messaggio_SC()
{
Console.Write("ERROR! ENTER THE SECRET CODE: ");
}
// *METODO CONTROLLO SECRET_CODE2*
public static int VERIFICA_SECRET_CODE_2(string valoreDaControllare)
{
int ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = Int32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.WriteLine("\n");
Messaggio_SC_2();
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
}
// *METODO MESSAGGIO SC*
public static void Messaggio_SC_2()
{
Console.Write("ERROR! ENTER THE CORRECT SECRET CODE: ");
}
public static int VERIFICA_CHOICE(string valoreDaControllare)
{
int ValoreControl = 0;
int a = 0;
bool res = false;
do
{
res = Int32.TryParse(valoreDaControllare, out ValoreControl);
if (res == true)
{
break;
}
Console.WriteLine("\n");
Messaggio_SC1();
// Console.ReadLine();
valoreDaControllare = Console.ReadLine();
} while (a != 1);
return ValoreControl;
}
// *METODO MESSAGGIO SC1*
public static void Messaggio_SC1()
{
Console.Clear();
Console.WriteLine("ENTER A CORRECT CHOICE! \n\n");
Console.WriteLine("CHOOSE AN OPTION: ");
Console.WriteLine();
Console.WriteLine("1. ADD PARAMS");
Console.WriteLine("2. EDIT PARAMS");
Console.WriteLine("3. DEL PARAMS");
Console.WriteLine("4. CHEAT MODE");
Console.WriteLine("5. CHANGE SECRET CODE");
Console.WriteLine("0. EXIT DEVELOPER MODE");
Console.WriteLine();
Console.Write("CHOICE: ");
}
#endregion
#region MAIN
public static void Main(string[] args)
{
#region VARIABILI
// *DICHIARAZIONE VARIABILI*
int scelta = 0, nn = 0, n = 0, num = 0, ra2 = 0, z = 0, xyz = 0, SECRET_CODE = 0;
uint n1 = 0, num1 = 0;
double pot = 0, ba = 0, esp = 0, pot1 = 0, ba1 = 0, esp1 = 0;
double a = 0, b = 0, c = 0, d = 0, e = 0, r = 0, r1 = 0, ra = 0, x = 0, y = 0, sc = 0, bs = 0, tot = 0, tot2 = 0;
ArrayList Fattoriale = new ArrayList();
string msg = "";
// VerificaNumero("");
#endregion
#region MENU
// *MENU*
do
{
Menu();
Console.Write("CHOICE: ");
#region TEST
/* *TEST*
VerificaNumero(Console.ReadLine());
bool con = false;
string tmpVal = Console.ReadLine();
con = verificaNumero(tmpVal);
if (con == true) {
scelta = int.Parse(Console.ReadLine());
} else {
}*/
#endregion
#region SCELTA
string sceltaStringa = "";
sceltaStringa = Console.ReadLine();
scelta = VerificaNumero(sceltaStringa);
// scelta = VerificaNumero(Console.ReadLine());
// int.Parse(Console.ReadLine());
Console.WriteLine("\n");
#endregion
#region SCELTA ERRATA
// *GESTIONE SCELTA ERRATA*
for (int ABC = 0; scelta != 1 && scelta != 2 && scelta != 3 && scelta != 4 && scelta != 5 && scelta != 6 && scelta != 7 && scelta != 8 && scelta != 9 && scelta != 10 && scelta != 0 && scelta != 05121999; ABC++)
{
Console.Clear();
Console.WriteLine("ENTER A VALID CHOICE. \n\n");
Menu();
Console.Write("CHOICE: ");
sceltaStringa = Console.ReadLine();
scelta = VerificaNumero(sceltaStringa);
// scelta = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
#endregion
#region SWITCH
// *GESTIONE SCELTE*
switch (scelta)
{
#region SCELTA 1
case 1: // *SCELTA 1 = ADDIZIONE*
Console.Clear();
double r2 = 0;
Console.Write("ENTER THE NUMBER OF ELEMENTS TO BE ADDED: ");
sceltaStringa = Console.ReadLine();
nn = VerificaNumero2(sceltaStringa);
// nn = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; i < nn; i++)
{
Console.Write($"ENTER ELEMENT NUMBER {i}: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
r2 += a;
}
Console.WriteLine("\nTHE SUM OF THE NUMBERS IS: {0}", r2);
break;
#endregion
#region SCELTA 2
case 2: // *SCELTA 2 = SOTTRAZIONE*
Console.Clear();
Console.Write("ENTER THE NUMBER OF ELEMENTS TO TAKE: ");
sceltaStringa = Console.ReadLine();
nn = VerificaNumero2(sceltaStringa);
// nn = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; i < nn; i++)
{
Console.Write($"ENTER ELEMENT NUMBER {i}: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
if (i == 0)
{
r = a;
}
else
{
r -= a;
}
}
Console.WriteLine("\nSUBTRACTION OF THE NUMBERS IS: {0}", r);
break;
#endregion
#region SCELTA 3
case 3: // *SCELTA 3 = MOLTIPLICAZIONE*
Console.Clear();
Console.Write("ENTER THE NUMBER OF ELEMENTS TO MULTIPLY: ");
sceltaStringa = Console.ReadLine();
nn = VerificaNumero2(sceltaStringa);
// nn = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; i < nn; i++)
{
Console.Write($"ENTER ELEMENT NUMBER {i}: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
if (i == 0)
{
r = a;
}
else
{
r *= a;
}
}
Console.WriteLine("\nMULTIPLICATION OF NUMBERS IS: {0}", r);
break;
#endregion
#region SCELTA 4
case 4: // *SCELTA 4 = DIVISIONE*
Console.Clear();
Console.Write("ENTER DIVIDEND: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("ENTER DIVIDER: ");
sceltaStringa = Console.ReadLine();
b = VerificaNumero2(sceltaStringa);
// b = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; b == 0; i++)
{
Console.WriteLine("IT'S NOT POSSIBLE TO DIVIDE A NUMBER PER ZERO. ENTER ANOTHER ISSUE. \n");
Console.Write("ENTER DIVIDER: ");
sceltaStringa = Console.ReadLine();
b = VerificaNumero2(sceltaStringa);
// b = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
x = a / b;
y = a % b;
Console.Write("THE QUOTIENT IS: {0}", x);
Console.WriteLine("\n");
Console.Write("THE REST IS: {0}", y);
do
{
Console.WriteLine("\n\nTO CONTINUE THE OPERATION ENTER 1. OTHERWISE ENTER 0.");
Console.Write("CHOICE: ");
sceltaStringa = Console.ReadLine();
z = VerificaNumero2(sceltaStringa);
// z = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; z != 1 && z != 0; i++)
{
Console.WriteLine("ERROR! INVALID CHOICE. ENTER ANOTHER CHOICE. ");
Console.Write("CHOICE: ");
sceltaStringa = Console.ReadLine();
z = VerificaNumero2(sceltaStringa);
// z = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
if (z == 1)
{
c = x;
Console.Write("ENTER DIVIDER: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; a == 0; i++)
{
Console.WriteLine("IT'S NOT POSSIBLE TO DIVIDE A NUMBER PER ZERO. ENTER ANOTHER ISSUE. \n");
Console.Write("ENTER DIVIDER: ");
sceltaStringa = Console.ReadLine();
a = VerificaNumero2(sceltaStringa);
// a = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
x = c / a;
y = c % a;
Console.Write("THE QUOTIENT IS: {0}", x);
Console.WriteLine("\n");
Console.Write("THE REST IS: {0}", y);
Console.WriteLine("\n");
}
else
{
if (z == 0)
{
Console.WriteLine("YOU HAVE CHOSEN TO TERMINATE THE OPERATION. ");
}
}
}
while (z == 1 && z != 0);
break;
#endregion
#region SCELTA 5
case 5: // *SCELTA 5 = RADICE QUADRATA*
Console.Clear();
Console.Write("ENTER THE NUMBER TO PROCESS: ");
sceltaStringa = Console.ReadLine();
ra = VerificaNumero2(sceltaStringa);
// ra = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
y = 0;
msg = "THE SQUARE ROUND IS: ";
for (x = 1; y != ra;)
{
x++;
y = x * x;
if (y > ra)
{
msg = "THE INPUT NUMBER IS NOT A PERFECT SQUARE ROUND. THE APPROXIMATE SQUARE ROUND IS: "; //Console.WriteLine($"THE INPUT NUMBER IS NOT A PERFECT SQUARE ROUND. THE APPROXIMATE SQUARE ROUND IS: {x-1}");
x -= 1;
break;
}
}
Console.WriteLine(msg + "{0}", x);
break;
#endregion
#region SCELTA 6
case 6: // *SCELTA 6 = POTENZA*
Console.Clear();
Console.Write("ENTER THE BASE: ");
sceltaStringa = Console.ReadLine();
ba = VerificaNumero2(sceltaStringa);
// ba = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("ENTER THE EXPONENT: ");
sceltaStringa = Console.ReadLine();
esp = VerificaNumero2(sceltaStringa);
// esp = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
pot = ba;
for (int i = 0; i < esp; i++)
{
pot *= ba;
}
pot /= ba;
Console.WriteLine("THE EXPONENTIATION IS: {0}", pot);
break;
#endregion
#region SCELTA 7
case 7: // *SCELTA 7 = FATTORIALE*
Console.Clear();
Console.Write("ENTER THE FACTORIAL BASE: ");
sceltaStringa = Console.ReadLine();
num1 = VerificaNumero3(sceltaStringa);
// num = Convert.ToInt32(Console.ReadLine());
n1 = num1;
Console.WriteLine("\n");
for (uint i = 0; num1 == 0; i++)
{
Console.WriteLine("ERROR! IT'S NOT POSSIBLE TO CALCULATE THE FACTORIAL OF A LOWER NUMBER OF 1. ENTER ANOTHER ISSUE. ");
Console.Write("ENTER THE FACTORIAL BASE: ");
sceltaStringa = Console.ReadLine();
num1 = VerificaNumero3(sceltaStringa);
// num = Convert.ToInt32(Console.ReadLine());
n1 = num1;
Console.WriteLine("\n");
}
while (num1 > 0)
{
n1 = num1;
for (uint i = n1 - 1; i > 0; i--)
{
n1 *= i;
}
Console.WriteLine("FACTORIAL OF {0}! = {1}\n", num1, n1);
num1--;
}
break;
#endregion
#region SCELTA 8
case 8: // *SCELTA 8 = TETRAZIONE*
Console.Clear();
Console.Write("ENTER THE BASE: ");
sceltaStringa = Console.ReadLine();
ba1 = VerificaNumero2(sceltaStringa);
// ba1 = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("ENTER THE NUMBER OF EXPONENTIATIONS TO BE MADE: ");
sceltaStringa = Console.ReadLine();
nn = VerificaNumero2(sceltaStringa);
// nn = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("ENTER THE EXPONENT: ");
sceltaStringa = Console.ReadLine();
esp1 = VerificaNumero2(sceltaStringa);
// esp1 = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int i = 0; i < nn; i++)
{
pot1 = ba1;
for (int j = 0; j < esp1; j++)
{
for (int k = 0; k < nn; k++)
{
pot1 *= ba1;
}
}
pot1 /= ba1;
}
Console.WriteLine("TETRACTION IS: {0}", pot1);
break;
#endregion
#region SCELTA 9
case 9: // *SCELTA 9 = RADICE CUBICA*
Console.Clear();
Console.Write("ENTER THE NUMBER TO PROCESS: ");
sceltaStringa = Console.ReadLine();
ra2 = VerificaNumero2(sceltaStringa);
// ra2 = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
y = 0;
msg = "THE CUBIC ROOT IS: ";
for (x = 0; y != ra2;)
{
x++;
y = x * x * x;
if (y > ra2)
{
msg = "THE INPUT NUMBER IS NOT A PERFECT CUBIC ROOT. THE APPROXIMATE CUBIC ROOT IS: "; //Console.WriteLine($"La cifra inserita non è un cubo perfetto. La radice cubica approssimata della base inserita è: {x-1}");
x -= 1;
break;
}
}
Console.WriteLine(msg + "{0}", x);
break;
#endregion
#region SCELTA 10
case 10: // *SCELTA 10 = PERCENTUALE*
Console.Clear();
Console.Write("ENTER THE BASE OF THE PERCENTAGE: ");
sceltaStringa = Console.ReadLine();
bs = VerificaNumero2(sceltaStringa);
Console.WriteLine("\n");
Console.Write("ENTER THE PERCENTAGE TO CALCULATE: ");
sceltaStringa = Console.ReadLine();
sc = VerificaNumero2(sceltaStringa);
Console.WriteLine("\n");
tot = (bs * sc) / 100;
tot2 = bs - tot;
Console.Write($"{sc}% OF {bs} IS: {tot}");
Console.WriteLine("\n");
Console.WriteLine($"THE REST OF THE PERCENTAGE IS: {tot2}");
break;
#endregion
#region DEVELOPER
case 05121999: // *DEVELOPER MODE*
Console.Clear();
Console.Write("YOU HAVE ENTERED DEVELOPER MODE... " +
"PLEASE ENTER THE SECRET CODE TO CONTINUE: ");
sceltaStringa = Console.ReadLine();
SECRET_CODE = VERIFICA_SECRET_CODE(sceltaStringa);
Console.WriteLine("\n");
for (int i = 0; SECRET_CODE != 05121999; i++)
{
Console.WriteLine("WRONG CODE!");
Console.Write("ENTER THE SECRET CODE: ");
sceltaStringa = Console.ReadLine();
SECRET_CODE = VERIFICA_SECRET_CODE(sceltaStringa);
Console.WriteLine("\n");
}
if (SECRET_CODE == 05121999)
{
int choice = 0, second_choice = 0, new_code = 0, new_code_2 = 0;
Console.WriteLine(" PASSWORD ACCEPTED...");
/* *TIMER TEST*
Console.WriteLine("\n");
Console.WriteLine("PLEASE WAIT...");
Timer.Tick += TimerEventProcessor;
Timer.Interval = 5000;
Timer.Start();
SetTimer();
aTimer.Elapsed += Elapsed;
aTimer.Start();
*/
Console.Write("\n\n PRESS ANY KEY TO CONTINUE...");
Console.ReadLine();
do
{
Console.Clear();
Console.WriteLine("CHOOSE AN OPTION: ");
Console.WriteLine();
Console.WriteLine("1. ADD PARAMS");
Console.WriteLine("2. EDIT PARAMS");
Console.WriteLine("3. DEL PARAMS");
Console.WriteLine("4. CHEAT MODE");
Console.WriteLine("5. CHANGE SECRET CODE");
Console.WriteLine("0. EXIT DEVELOPER MODE");
Console.WriteLine("\n");
Console.Write("CHOICE: ");
sceltaStringa = Console.ReadLine();
choice = VERIFICA_CHOICE(sceltaStringa);
Console.WriteLine("\n");
for (int i = 0; choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 5 && choice != 0; i++)
{
Console.Clear();
Console.WriteLine("ENTER A CORRECT CHOICE! \n\n");
Console.WriteLine("CHOOSE AN OPTION: ");
Console.WriteLine();
Console.WriteLine("1. ADD PARAMS");
Console.WriteLine("2. EDIT PARAMS");
Console.WriteLine("3. DEL PARAMS");
Console.WriteLine("4. CHEAT MODE");
Console.WriteLine("5. CHANGE SECRET CODE");
Console.WriteLine("0. EXIT DEVELOPER MODE");
Console.WriteLine();
Console.Write("CHOICE: ");
sceltaStringa = Console.ReadLine();
choice = VERIFICA_CHOICE(sceltaStringa);
Console.WriteLine("\n");
}
switch (choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
Console.Clear();
Console.Write("ENTER THE CURRENT SECRET CODE: ");
sceltaStringa = Console.ReadLine();
second_choice = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
if (second_choice == SECRET_CODE)
{
Console.Write("ENTER THE NEW SECRET CODE: ");
sceltaStringa = Console.ReadLine();
new_code = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
Console.Write("REPEAT THE NEW SECRET CODE: ");
sceltaStringa = Console.ReadLine();
new_code_2 = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
if (new_code == new_code_2)
{
Console.Write($"SECRET CODE UPDATED. THE NEW SECRET CODE IS: <{new_code}>");
SECRET_CODE = new_code;
Console.WriteLine("\n\nNOW YOU WILL RETURN TO THE PROGRAM'S HOME PAGE... ");
Console.WriteLine("\nPRESS ANY KEY TO CONTINUE... ");
Console.ReadLine();
break;
}
else
{
for (int j = 0; new_code != new_code_2; j++)
{
Console.WriteLine("\nERROR! THE TWO CODES ARE DIFFERENT! ENTER IN THE FIELD THE SAME CODE OF THE FIRST. ");
Console.Write("ENTER THE NEW SECRET CODE: ");
sceltaStringa = Console.ReadLine();
new_code = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
Console.Write("REPEAT THE NEW SECRET CODE: ");
sceltaStringa = Console.ReadLine();
new_code_2 = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
}
}
}
else
{
for (int f = 0; second_choice != SECRET_CODE; f++)
{
Console.WriteLine("\nERROR! WRONG CODE! ENTER THE CORRECT CURRENT SECRET CODE. ");
Console.Write("ENTER THE CURRENT SECRET CODE: ");
sceltaStringa = Console.ReadLine();
second_choice = VERIFICA_SECRET_CODE_2(sceltaStringa);
Console.WriteLine("\n");
}
}
break;
}
} while (choice != 0);
Console.Clear();
Console.WriteLine(" YOU HAVE LEFT THE DEVELOPER MODE...");
Console.WriteLine("\n");
Console.Write(" PRESS ANY KEY TO CONTINUE...");
}
break;
#endregion
#region SCELTA 0
case 0: // *SCELTA 0 = EXIT*
Console.Clear();
Console.WriteLine("\nYOU HAVE CHOSEN TO TERMINATE THE PROGRAM. ");
break;
#endregion
#region SCELTA DEFAULT
default:
Console.Clear();
Console.WriteLine("IMPOSSIBLE! ");
break;
#endregion
}
#endregion
Console.ReadLine();
Console.Clear();
}
while (scelta != 0);
#endregion
}
#endregion
}
#endregion
}
#endregion
#region TESTS
/* *TEST DECIMAL*
// 6.1283738070791493602393614220176664011587311950256367795624200686294530200719566092674689125517947158833789... × 10^1355310569403873
*/
/* *TEST COSTANTI*
private const int A = 1;
private const int B = 2;
private const int C = 3;
private const int D = 4;
private const int E = 5;
private const int F = 6;
private const int G = 7;
private const int H = 8;
private const int I = 9;
private const int L = 0;
*/
/* *TEST FATTORIALE*
Console.WriteLine("Inserire la base del fattoriale: ");
d = double.Parse(Console.ReadLine());
Fattoriale.Add(d);
for (int i = 0; i < d; i++)
{
Fattoriale.Add(d - 1);
}
Console.WriteLine("\n");
for (int i = 0; d < 1; i++)
{
Console.WriteLine("Il fattoriale può essere applicato solo a numeri positivi. Inserire un altro numero. \n");
Console.WriteLine("Inserire la base del fattoriale: ");
d = double.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
if (d == 1)
{
Console.WriteLine($"Il fattoriale del numero inserito è: ", d);
Console.WriteLine("\n");
}
for (int k = 0; k < d; k++)
{
e = Fattoriale[d] * Fattoriale[k];
}
Console.WriteLine($"Il fattoriale del numero inserito è: ", d);
Console.WriteLine("\n");
*/
/* *TEST DIVISIONE*
Console.WriteLine("Inserire il numero di elementi da dividere: ");
nn = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
if ((nn / 2) == 0)
{
for (int i = 0; i < (nn / 2); i++)
{
Console.WriteLine("Inserire divisore: ");
a = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.WriteLine("Inserire divisore: ");
b = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int j = 0; b == 0; j++)
{
Console.WriteLine("Non puoi dividere un numero per zero. Inserire un altro numero. \n");
Console.WriteLine("Inserire il divisore: ");
b = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
if (i == 0)
{
r = a;
}
else
{
r /= b;
}
}
}
else
{
for (int i = 0; i < ((nn / 2) + 1); i++)
{
Console.WriteLine("Inserire divisore: ");
a = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.WriteLine("Inserire divisore: ");
b = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
for (int j = 0; b == 0; j++)
{
Console.WriteLine("Non puoi dividere un numero per zero. Inserisci un altro numero. \n");
Console.WriteLine("Inserisci il divisore: ");
b = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
}
if (i == 0)
{
r = a;
}
else
{
r /= b;
}
}
}
*/
/* *TEST METODO*
public static bool verificaNumero(string valoreDaControllare) {
int a = 0;
int numero = 0;
do {
try {
numero = int.Parse(Console.ReadLine());
return true;
} catch (FormatException) {
return false;
}
} while (a != 1);
}
*/
#endregion
Ultima modifica: