-
Notifications
You must be signed in to change notification settings - Fork 0
Fisrt try #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Var-S
wants to merge
3
commits into
main
Choose a base branch
from
1try
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fisrt try #1
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| using System.Text.Json; | ||
| namespace SectTask; | ||
|
|
||
| public class CommandParser | ||
| { | ||
| public void Commands(string?[] args) | ||
| { | ||
| Methods td = new Methods(); | ||
| for (int i = 0; i < args.Length - 1; ++i) | ||
| { | ||
| try | ||
| { | ||
| switch (args[i]) | ||
| { | ||
| case "/add": | ||
| SubTask sub = new SubTask(Convert.ToBoolean(args[i + 1]), args[i + 2], args [i + 3]); | ||
| td.AddTask(Convert.ToInt32(args[i + 4]), sub,Convert.ToDateTime(args[i + 5]),Convert.ToBoolean(args[i + 6])); | ||
| break; | ||
| case "/all": | ||
| td.ShowTasks(); | ||
| break; | ||
| case "/delete": | ||
| td.DeleteTask(Convert.ToInt32(args[i + 1])); | ||
| break; | ||
| case "/save": | ||
| td.toFile(args[i + 1]); | ||
| break; | ||
| case "/load": | ||
| td.fromFile(args[i + 1]); | ||
| break; | ||
| case "/completed": | ||
| td.ChangeStatus(Convert.ToInt32(args[i + 1])); | ||
| break; | ||
| case "/create-group": | ||
| td.CreateGroup(Convert.ToInt32(args[i + 1])); | ||
| break; | ||
| case "/delete-group": | ||
| td.DeleteGroup(Convert.ToInt32(args[i + 1])); | ||
| break; | ||
| case "/add-to-group": | ||
| td.AddToGroup(Convert.ToInt32(args[i + 1]), Convert.ToInt32(args[i + 2])); | ||
| break; | ||
| case "/delete-from-group": | ||
| td.DeleteFromGroup(Convert.ToInt32(args[i + 1]), Convert.ToInt32(args[i + 2])); | ||
| break; | ||
| case "/add-subtask": | ||
| SubTask sub1 = new SubTask(Convert.ToBoolean(args[i + 1]), args[i + 2], args [i + 3]); | ||
| td.AddSubTask(Convert.ToInt32(args[i + 2]), sub1 ); | ||
| break; | ||
| case "/change-sub-status": | ||
| td.ChangeSubStatus(Convert.ToInt32(args[i + 1])); | ||
| break; | ||
| case "/today": | ||
| td.DayCheck(); | ||
| break; | ||
| } | ||
| } | ||
| catch (ArgumentException ep) | ||
| { | ||
| Console.WriteLine(ep.Message); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| namespace SectTask; | ||
| using System.Text.Json; | ||
|
|
||
| public class Methods | ||
| { | ||
| private List<Task?> _taskData = new List<Task?>(); | ||
| private List<Group?> _groupData = new List<Group?>(); | ||
| private List<SubTask?> _subData = new List<SubTask?>(); | ||
|
|
||
| public void AddTask(int id, SubTask sub, DateTime deadline, bool complete) | ||
| { | ||
| _taskData.Add(new Task() {TaskId = id, Sub = sub, DeadLine = deadline, TaskStatus = complete} ); | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| Console.WriteLine("Task Created!"); | ||
| } | ||
|
|
||
| public void AddSubTask(int Taskid, SubTask sub) | ||
| { | ||
| foreach (var t in _taskData.Where(t => t!.TaskId == Taskid)) | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| { | ||
| t!.Sub = sub; | ||
| } | ||
|
|
||
| Console.WriteLine("SubTask Created!"); | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| public void ChangeSubStatus(int id) | ||
| { | ||
| foreach (var t in _subData.Where(t => t!.SubStatus == false)) | ||
| { | ||
| t!.SubStatus = true; | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| } | ||
| Console.WriteLine("Status Changed!"); | ||
| } | ||
| public void ShowTasks() | ||
| { | ||
| foreach (var t in _taskData) | ||
| { | ||
| Console.WriteLine(t!.TaskId); | ||
| Console.WriteLine(t!.TaskStatus); | ||
| var json = JsonSerializer.Serialize(t?.Sub); | ||
| var json1 = JsonSerializer.Serialize(t?.DeadLine); | ||
| Console.WriteLine(json); | ||
| Console.WriteLine(json1); | ||
| } | ||
| } | ||
|
|
||
| public void ShowTasks(int id) | ||
| { | ||
| foreach (var t in _taskData) | ||
| { | ||
| if (t!.TaskId == id){ | ||
| Console.WriteLine(t!.TaskId); | ||
| Console.WriteLine(t!.TaskStatus); | ||
| var json = JsonSerializer.Serialize(t?.Sub); | ||
| var json1 = JsonSerializer.Serialize(t?.DeadLine); | ||
| Console.WriteLine(json); | ||
| Console.WriteLine(json1); | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("Wrong Id"); | ||
| } | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
|
|
||
| public void DeleteTask(int id) | ||
| { | ||
| for (var i = 0; i < _taskData.Count; ++i) | ||
| { | ||
| if (_taskData[i]!.TaskId == id) | ||
| { | ||
| _taskData.Remove(_taskData[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void ChangeStatus(int id) | ||
| { | ||
| foreach (var t in _taskData.Where(t => t!.TaskStatus == false)) | ||
| { | ||
| t!.TaskStatus = true; | ||
| } | ||
| Console.WriteLine("Status Changed!"); | ||
| } | ||
|
|
||
| public void toFile(string? ph) | ||
| { | ||
| var str = new StreamWriter(ph!); | ||
| foreach (var t in _taskData) | ||
| { | ||
| str.WriteLine(t!.TaskId); | ||
| str.WriteLine(t!.TaskStatus); | ||
| var json = JsonSerializer.Serialize(t?.Sub); | ||
| var json1 = JsonSerializer.Serialize(t?.DeadLine); | ||
| str.WriteLine(json); | ||
| str.WriteLine(json1); | ||
| } | ||
| str.Close(); | ||
| } | ||
|
|
||
| public void fromFile(string? ph) | ||
| { | ||
| if (File.Exists(ph)) | ||
| { | ||
| using StreamReader reader = new StreamReader(ph); | ||
| _taskData.Clear(); | ||
| for (int i = 0; i < System.IO.File.ReadAllLines(ph).Length; ++i) | ||
| { | ||
| string? json = reader.ReadLine(); | ||
| if (json != null) _taskData.Add(JsonSerializer.Deserialize<Task>(json)); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("File not found"); | ||
| } | ||
|
Var-S marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public void DayCheck() | ||
| { | ||
| foreach (var json in from t in _taskData where t!.DeadLine.Day == DateTime.Now.Day select JsonSerializer.Serialize(t)) | ||
| { | ||
| Console.WriteLine(json); | ||
| } | ||
| } | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
|
|
||
| public void CreateGroup(int id) | ||
| { | ||
| _groupData.Add(new Group(){GroupId = id,Tasks = null}); | ||
| } | ||
|
|
||
| public void AddToGroup(int Taskid, int Groupid) | ||
| { | ||
| foreach (var t in _taskData.Where(t => t!.TaskId == Taskid)) | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| { | ||
| foreach (var t1 in _groupData.Where(t1 => t1!.GroupId == Groupid)) | ||
| { | ||
| t1!.Tasks = t; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void ShowGroup() | ||
| { | ||
| foreach (var t in _groupData) | ||
| { | ||
| var json = JsonSerializer.Serialize(t!.GroupId); | ||
| var json1 = JsonSerializer.Serialize(t!.Tasks); | ||
| if (json == "null") | ||
| { | ||
| Console.Write(""); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine(json); | ||
| } | ||
| if (json1 == "null") | ||
| { | ||
| Console.Write(""); | ||
| } | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| else | ||
| { | ||
| Console.WriteLine(json1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void DeleteGroup(int id) | ||
| { | ||
| foreach (var t in _groupData) | ||
| { | ||
| if (t!.GroupId == id) | ||
| { | ||
| t.Tasks = null; | ||
| t.GroupId = null; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void DeleteFromGroup(int Groupid, int Taskid) | ||
| { | ||
| for (int i = 0; i < _groupData.Count; ++i) | ||
| { | ||
| if (_groupData[i]!.GroupId == Groupid) | ||
| { | ||
| for (int j = 0; j < _taskData.Count; ++j) | ||
| { | ||
| if (_taskData[j]!.TaskId == Taskid) | ||
| { | ||
| _groupData[i]!.Tasks = null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System.ComponentModel.Design.Serialization; | ||
|
|
||
| namespace SectTask; | ||
|
|
||
| static class Program | ||
| { | ||
| static void Main(string?[] args) | ||
| { | ||
| CommandParser input = new CommandParser(); | ||
| input.Commands(args); | ||
| } | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| namespace SectTask; | ||
|
|
||
| public class SubTask | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| { | ||
| public bool SubStatus { get; set; } | ||
|
|
||
| public string? Name { get; set; } | ||
|
|
||
| public string? Description { get; set; } | ||
|
|
||
| public SubTask(bool complete, string? name, string? description) | ||
| { | ||
| SubStatus = complete; | ||
| Name = name; | ||
| Description = description; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public class Task | ||
| { | ||
| public SubTask Sub; | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| public int TaskId { get; set; } | ||
|
|
||
| public bool TaskStatus { get; set; } | ||
| public DateTime DeadLine { get; set; } // 01.01.0001 0:00:00 | ||
|
|
||
| public Task(int id, SubTask sub, DateTime deadline, bool status) | ||
| { | ||
| TaskId = id; | ||
| Sub = sub; | ||
| DeadLine = deadline; | ||
| TaskStatus = status; | ||
| } | ||
|
|
||
| public Task() { } | ||
| } | ||
|
|
||
| public class Group | ||
|
Var-S marked this conversation as resolved.
Outdated
|
||
| { | ||
| public Task? Tasks; | ||
| public int? GroupId { get; set; } | ||
| } | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.