Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace esercizio_enum
- {
- enum ShapeType { Square, Triangle, Rectangle, Last }
- class Program
- {
- static void PrintShape(ShapeType t)
- {
- int height;
- int width;
- switch (t)
- {
- case ShapeType.Square:
- width = 3;
- height = 2;
- PrintRect(height, width);
- break;
- case ShapeType.Triangle:
- height = 3;
- PrintTriangle(height);
- break;
- case ShapeType.Rectangle:
- width = 4;
- height = 2;
- PrintRect(height, width);
- break;
- }
- }
- static void PrintShape(int t)
- {
- int height;
- int width;
- switch (t)
- {
- case 0:
- width = 3;
- height = 2;
- PrintRect(height, width);
- Console.WriteLine("test se funziona conversione");
- break;
- case 1:
- height = 3;
- PrintTriangle(height);
- Console.WriteLine("test se funziona conversione");
- break;
- case 2:
- width = 4;
- height = 2;
- PrintRect(height, width);
- Console.WriteLine("test se funziona conversione");
- break;
- }
- }
- static void PrintShape(string shape)
- {
- int height;
- int width;
- switch (shape.ToLower())
- {
- case "square":
- width = 3;
- height = 2;
- PrintRect(height, width);
- break;
- case "triangle":
- height = 3;
- PrintTriangle(height);
- break;
- case "rectangle":
- width = 4;
- height = 2;
- PrintRect(height, width);
- break;
- }
- }
- static void PrintAst(int n)
- {
- for (int i = 0; i < n; i++)
- {
- Console.Write("*");
- }
- }
- static void PrintTriangle(int width)
- {
- for (int i = 1; i <= width; i++)
- {
- PrintAst(i);
- Console.WriteLine("\n");
- }
- }
- static void PrintSquare(int width)
- {
- PrintRect(width, width);
- }
- static void PrintRect(int height, int width)
- {
- for (int i = 0; i < height; i++)
- {
- PrintAst(width);
- Console.WriteLine("\n");
- }
- }
- static void Main(string[] args)
- {
- //PrintRect(2, 4);
- //PrintAst(3);
- Console.WriteLine("Regole: Puoi digitare un numero, o il nome associato per disegnare");
- Console.WriteLine("0)Square, 1)Triangle 2)Rectangle");
- Console.WriteLine("cosa vuoi disegnare?");
- string a = Console.ReadLine();
- int test;
- if (a.Length == 1)
- {
- test = int.Parse(a);
- PrintShape(test);
- }
- else
- {
- PrintShape(a);
- }
- //PrintShape(a);
- //PrintSquare(4);
- //PrintTriangle(3);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement