diff --git a/lab3/app/Main.hs b/lab3/app/Main.hs index eb574f9..4f1807b 100644 --- a/lab3/app/Main.hs +++ b/lab3/app/Main.hs @@ -1,28 +1,31 @@ module Main (main) where +import Text.Read (readMaybe) import Codec.Picture import qualified Data.Vector.Unboxed as VU import Lib -caesarShift :: Int -caesarShift = 66 - -bitsPerByte :: Int -bitsPerByte = 1 - -sourceTextPath :: String -sourceTextPath = "resources/biography.txt" -sourceImagePath :: String -sourceImagePath = "resources/david.bmp" -encodedImagePath :: String -encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp" -decodedTextPath :: String -decodedTextPath = "tmp/biography.txt" - main :: IO () main = do - putStrLn $ "Чтение текста из файла \"" ++ sourceTextPath ++ "\"" + putStrLn "Введите значение сдвига для шифра Цезаря:" + inputCaesarShift <- getLine + let caesarShift = case readMaybe inputCaesarShift of + Just value -> value + Nothing -> error "Ожидалось целое число!" + + putStrLn "Введите количество бит для кодирования:" + inputBitsPerByte <- getLine + let bitsPerByte = case readMaybe inputBitsPerByte of + Just value -> value + Nothing -> error "Ожидалось целое число!" + + let sourceTextPath = "resources/biography.txt" + let sourceImagePath = "resources/david.bmp" + let encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp" + let decodedTextPath = "tmp/biography.txt" + + putStrLn $ "\nЧтение текста из файла \"" ++ sourceTextPath ++ "\"" inputText <- readFile sourceTextPath putStrLn $ "10 символов текста: \"" ++ take 10 inputText ++ "\""