From 571578b0225c9e4d5a55becac483aab9f1b53816 Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Mon, 22 Jul 2024 18:45:54 +0300 Subject: [PATCH] Edit Lesson 5 Task 2 --- Lesson_5/Task_1/autoservice.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lesson_5/Task_1/autoservice.cpp b/Lesson_5/Task_1/autoservice.cpp index 3679f1d..b58097a 100644 --- a/Lesson_5/Task_1/autoservice.cpp +++ b/Lesson_5/Task_1/autoservice.cpp @@ -1,6 +1,5 @@ #include "autoservice.h" #include "ui_autoservice.h" -#include AutoService::AutoService(QWidget *parent) : QMainWindow(parent) @@ -26,10 +25,13 @@ void AutoService::filter() bool typeEmpty = ui->e_type->text().isEmpty(); bool priceEmpty = ui->e_price->text().isEmpty(); for (int automobile = 0; automobile < m_automobiles.size(); ++automobile) { + bool manufacturerMatch = m_automobiles[automobile]->getManufacturer() == ui->e_manufacturer->text(); + bool typeMatch = m_automobiles[automobile]->getType().contains(ui->e_type->text()); + bool priceMatch = m_automobiles[automobile]->getPrice() <= ui->e_price->text().toInt(); if ( - (manufacturerEmpty || m_automobiles[automobile]->getManufacturer() == ui->e_manufacturer->text()) - && (typeEmpty || (m_automobiles[automobile]->getType().contains(ui->e_type->text()))) - && (priceEmpty || (m_automobiles[automobile]->getPrice() <= ui->e_price->text().toInt())) + (manufacturerEmpty || manufacturerMatch) + && (typeEmpty || typeMatch) + && (priceEmpty || priceMatch) ) addAutomobile(m_automobiles[automobile]);