From d7470c7157dd6c81bd9365029661c995c08cfc79 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Sun, 27 Feb 2022 19:31:46 +0300 Subject: [PATCH] [PPM] Use existing constant magic number instead of specifying it everywhere manually --- src/pnm.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pnm.cpp b/src/pnm.cpp index af81d6a..0599df6 100644 --- a/src/pnm.cpp +++ b/src/pnm.cpp @@ -29,6 +29,8 @@ class Color { public: Color() {} ~Color() {} + + bool operator==(const Color& other); }; class RGB : public Color { @@ -127,7 +129,7 @@ public: // check for magic number std::string entity; ppm_image_file >> entity; - if (entity != "P6") { + if (entity != m_MAGIC_NUMBER) { throw std::runtime_error("Does not have a magic number"); } @@ -178,7 +180,7 @@ public: // write to the file on the disk and close it // magic number - ppm_image_file << "P6"; + ppm_image_file << m_MAGIC_NUMBER; // newline ppm_image_file << "\n";