Advertisement
angryatti

Hungarian PlateNumber Generator v1 Cplusplus

Jul 8th, 2023
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include "platenumb.h"
  2. #include "./ui_platenumb.h"
  3. #include <unordered_set>
  4.  
  5. PlateNumb::PlateNumb(QWidget *parent)
  6.     : QMainWindow(parent)
  7.     , ui(new Ui::PlateNumb)
  8. {
  9.     ui->setupUi(this);
  10.     ui->GenPlateBT1->setVisible(false);
  11.  
  12. }
  13.  
  14. PlateNumb::~PlateNumb()
  15. {
  16.     delete ui;
  17. }
  18.  
  19. std::unordered_set <QString> setPlate;
  20.  
  21. QString genPlate ="";
  22.  
  23. void PlateNumb::on_GenPlateBT1_clicked()
  24. {
  25.  
  26.  
  27.  
  28.     QString albet;
  29.     char al2;
  30.     genPlate="";
  31.     for (int ch = 'A'; ch <= 'Z'; ch++) {
  32.         al2=(char)ch;
  33.         albet+=al2;
  34.     }
  35.  
  36.  
  37.  
  38.     for (int i=0;i<4;i++){
  39.         int randTemp = rand() % albet.length();
  40.  
  41.         genPlate.append(albet[randTemp]);
  42.     }
  43.  
  44.     genPlate.append("-") ;
  45.     for (int i=0;i<3;i++){
  46.  
  47.         int randTemp = rand() % 10;
  48.         genPlate.append(QString::number(randTemp));
  49.  
  50. }
  51.     setPlate.insert(genPlate);
  52.  
  53.  
  54. }
  55.  
  56. void PlateNumb::on_GenLotBT2_clicked()
  57. {
  58.   for (int i =0; i<100;i++){
  59.         PlateNumb::on_GenPlateBT1_clicked();
  60.   }
  61.   for (auto i = setPlate.begin();i!=setPlate.end();i++)
  62.   {
  63.         ui->GennedPlateListLE1->append(*i);
  64.  
  65.   }
  66.  
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement