Skip to content

Lzw.homework3#8

Open
MinyazevR wants to merge 7 commits intomainfrom
LZW.Homework3
Open

Lzw.homework3#8
MinyazevR wants to merge 7 commits intomainfrom
LZW.Homework3

Conversation

@MinyazevR
Copy link
Copy Markdown
Owner

No description provided.

Comment thread Homework3/LZW/LZW/Bor.cs Outdated
/// <summary>
/// A class representing the bor data structure
/// </summary>
public class Bor
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Он Trie

Comment thread Homework3/LZW/LZW/Bor.cs Outdated
Comment on lines +28 to +31
public int GetCode()
{
return currentNode.Code;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public int GetCode()
{
return currentNode.Code;
}
public int GetCode()
=> currentNode.Code;

Comment thread Homework3/LZW/LZW/Bor.cs Outdated
/// <summary>
/// Function to add a byte
/// </summary>
/// <param name="byteToAdd"> byte to add </param>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="byteToAdd"> byte to add </param>
/// <param name="byteToAdd"> Byte to add </param>

Comment thread Homework3/LZW/LZW/LZW.cs Outdated
Comment on lines +35 to +37
{

string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress);
{
string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress);

После открывающей фигурной скобки пустая строка не ставится

Comment thread Homework3/LZW/LZW/LZW.cs
using FileStream fs = new(fileName, FileMode.Create);

// Reading all bytes from a file
var stringToConvert = File.ReadAllBytes(pathToFileToCompress);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще, может быть плохой идеей читать файл в память целиком. Файлы бывают большие. Тем более что LZW может работать побайтово. Но это можно не править, для учебных целей вполне ок.

Comment thread Homework3/LZW/LZW/Solution.cs Outdated
{
if (args.Length != 2)
{
throw new FileNotFoundException();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, а кто его поймает, если исключение бросается прямо из Main- а? Тут надо вежливо поругаться и рассказать, какие параметры программа ожидает.

Comment thread Homework3/LZW/LZW/Solution.cs Outdated
if (args[1] == "-u")
{
LZW.DecompressFile(pathToFile);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если не -c и не -u, то надо что-то сказать пользователю

Comment thread Homework3/LZW/LZWTest/BorTest.cs Outdated

public class BorTest
{
Bor bor = new();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Bor bor = new();
private Bor bor = new();

Comment thread Homework3/LZW/LZWTest/LZWTest.cs Outdated
var firstString = File.ReadAllBytes(filename);
var secondString = File.ReadAllBytes("..//..//..//Test");
Assert.AreEqual(firstString, secondString);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На одном файле работает. А на пустом, на текстовом/бинарном?

Comment thread Homework3/LZW/LZW/LZW.cs Outdated
{

string fileName = Path.GetFileNameWithoutExtension(pathToFileToCompress);
fileName = $"{pathToFileToCompress}..//..//{fileName}.zipped";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так мы теряем расширение файла в процессе запаковки/распаковки, что не очень.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants