https://github.com/karpovpaulus/2048windowsformsapp
🎮 A copy of the popular game "2048", written in the process of learning Windows Forms technology, with results stored in JSON format.
https://github.com/karpovpaulus/2048windowsformsapp
csharp json windows-forms
Last synced: 5 months ago
JSON representation
🎮 A copy of the popular game "2048", written in the process of learning Windows Forms technology, with results stored in JSON format.
- Host: GitHub
- URL: https://github.com/karpovpaulus/2048windowsformsapp
- Owner: KarpovPaulus
- Created: 2024-04-26T14:51:13.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-15T13:15:43.000Z (about 2 years ago)
- Last Synced: 2025-01-02T22:46:19.561Z (over 1 year ago)
- Topics: csharp, json, windows-forms
- Language: C#
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🎮 2048WindowsFormsApp
## 🔢 A copy of the popular game "2048", written in the process of learning Windows Forms technology, with results stored in JSON format.

## 🔧 Technical part
* The project is implemented on the Windows Forms platform.
* Made in compliance with the principles of OOP.
* The JSON format is used to save the results.
## 💾 Serialization
Using JSON serialization and deserialization, you can save and load game results.
~~~ csharp
namespace _2048WindowsFormsApp
{
public class UserManager
{
public static string path = "result.json";
public static List GetAll()
{
if(FileProvider.Exists(path))
{
var jsonData = FileProvider.GetValue(path);
return JsonConvert.DeserializeObject>(jsonData);
}
return new List();
}
public static void Add(User newUser)
{
var users = GetAll();
users.Add(newUser);
var jsonData = JsonConvert.SerializeObject(users);
FileProvider.Replace(path, jsonData);
}
}
}
~~~~