Last active
August 29, 2019 23:42
-
-
Save vitorpiovezam/3c0b7e972f7eac14f6b87d094aa2636e to your computer and use it in GitHub Desktop.
Entediado na aula de c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class FOO { | |
public static void Main() { | |
var category = new Category("Maquiagem"); | |
var product = new Product("Vareta", "[email protected]", category); | |
var categoryRepository = new CategoryRepository(); | |
var productRepository = new ProductRepository(); | |
Console.WriteLine(category.mandaLetra()); | |
Console.WriteLine(product.mandaLetra()); | |
productRepository.Insert(product); | |
productRepository.Update(product); | |
productRepository.Delete(product); | |
categoryRepository.Insert(category); | |
categoryRepository.Update(category); | |
categoryRepository.Delete(category); | |
} | |
public class Category: BaseModel { | |
public String name; | |
public Category(String name): base() { | |
this.name = name; | |
} | |
} | |
public class Product: BaseModel { | |
public String name; | |
public String email; | |
public Category category; | |
public Product(String name, String email, Category category): base() { | |
this.name = name; | |
this.email = email; | |
this.category = category; | |
} | |
} | |
public class ProductRepository: BaseService < Product > { | |
} | |
public class CategoryRepository: BaseService < Category > { | |
} | |
public abstract class BaseModel { | |
public int id; | |
public BaseModel() { | |
this.id = generateId(); | |
} | |
public int generateId() { | |
Random randNum = new Random(); | |
return randNum.Next(100000); | |
} | |
public String mandaLetra() { | |
return "Salve -> " + this.ToString(); | |
} | |
} | |
public abstract class BaseService < T > { | |
public void Insert(T item) { | |
Console.WriteLine("Aeeee cadastrou"); | |
Console.WriteLine("\n\n " + item.ToString()); | |
} | |
public void Update(T item) { | |
Console.WriteLine("Aeeee atualizou"); | |
Console.WriteLine("\n\n " + item.ToString()); | |
} | |
public void Delete(T item) { | |
Console.WriteLine("Aeeee deletou"); | |
Console.WriteLine("\n\n " + item.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment