Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active April 8, 2016 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/3002ba45915f9997068ad0e253831701 to your computer and use it in GitHub Desktop.
Save conanak99/3002ba45915f9997068ad0e253831701 to your computer and use it in GitHub Desktop.
// Student bây giờ chỉ chứa thông tin
public class Student {
public string Name { get; set;}
public int Age { get; set;}
}
// Class này chỉ format thông tin hiển thị student
public class Formatter {
public string FormatStudentText(Student std) {
return "Name: " + std.Name + ". Age: " + std.Age;
}
public string FormatStudentHtml(Student std) {
return "<span>" + std.Name + " " + std.Age + "</span>";
}
public string FormatStudentJson(Student std) {
return Json.Serialize(std);
}
}
// Class này chỉ lo việc lưu trữ
public class Store {
public void SaveToDatabase(Student std) {
dbContext.Save(std);
}
public void SaveToFile(Student std) {
Files.Save(std, "fileName.txt");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment