🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"

This is going to be a banking project in C++ with a graphical user interface, randomly generated data with 40 customers and using lightweight storage for files. Let's have a look at the main features:
Using lightweight storage for files eg. a text file. Store and retrieve data without extra burden on the device.
Using a lightweight GUI library eg. Qt for a responsive and interactive user interface.
Standard library of C++.
Used for file handling, random data and number generation.
GUI library
Qt
It is cross - platform and quite popular.
WxWidgets
It is beginner-friendly and lightweight.
Storage for data
Using CSV or binary file, which is a lightweight option.
struct Customer {
std:: string name;
int accountNumber;
double balance;
};
Banking logic:
Creation of a class ,bank, for handling the different functionalities.
Using functions eg. deposit (), withdrawal, and get balance().
Storing data of customers in file.eg.
std:: ofstream
out file( " customer.CSV");
GUI development...
If using Qt , qt designer can be utilized. GUI buttons can be connected to banking logic.
Testing..
All functionalities can be tested with random data .
Code...
#include<iostream>
#include<fstream>
#include<random>
#include<vector>
#include<string>
Customer structure
struct customer {
Std:: string name;
int account number;
double balance;
};
// Customer prototypes
void generateCustomers(
std:: vector<Customer>&
customers);
void deposit ( Customer & customers)
double amount);
void saveData( const
std:: vector<Customer> & customers);
int main (){
std:: vector< Customer>customers;
generateCustomer (customers);
// GUI logic interaction with customers:
saveData customers ();
return 0;
}
// Definition of functions
void generateCustomers(std:: vector <Customer>& customers;
{
// Random generation logic.
}
void deposit ( Customer & customers
double amount) {
customer.balance += amount;
}
void withdraw ( Customer & customers,
double amount){
if( customer.balance >= amount){
customer.balance -= amount;
} else {
std:: cout << " insufficient balance \n";
}
}
void saveData ( const
std:: vector<Customers>
& customers) {
std:: ofstream
file ( " customers.CSV");
for ( const auto & customer: customers) {
file << customer.name <<","<<
customer.accountNumber<<"," << customer.balance <<"\n" ;
}
}
GUI library
For lightweight library , FLTK ( Fast Light Toolkit) is fast, easy and small so that there is minimal burden on device
Installation..
FLTK
Download FLTK : FLTK downloads on windows.
Now extract the file that you downloaded. Build it's library by using CMake or open the.sln file.It is provided and you can open it in visual studio. Now you can build it.
On Linux
sudo apt- get install libfltk1.3- dev
On macOS
brew install FLTK
Make a basic FLTK application. Try a simple
example to test if FLTK is correctly installed.
#include <
brew install
FLTK
Example....
#include<FL/FI.H>
#include<FL/FI_WINDOW.H>
#include<FL/FI_BUTTON.H>
// Callback function for button click.
void buttonCallback( FI_Widget*widget, void* data){
FI_Button*button = static_cast<FI_button*>
(widget)
button ->label("clicked") ;
}
int main (){
FI_Window window (400,300," Banking project")
FI_Button, button (150,120,100,40,"click me");
button.callback(buttonCallback) ;
window.show();
return FI::run();
}
Now you can compile the program by using your compiler with FLTK flags.
Code
g++ -0. banking project main.cpp - lfltk
Build GUI for the banking project.
A simple interface can be designed with....
Input boxes for account numbers , amounts etc,.
Buttons for actions like deposit , withdraw and balance inquiry.
Labels to show messages and balance.
This is the outline for it
Code
#include< FL/FI.H>
#include< FL/FI_Window.H>
#include<FL/FI_Input.H>
#include<FL/FI_Button.H>
#include<FL/FI_Output.H>
#include<vector>
#include<string>
#include<cstdlib>
//Structure for customer data
struct Customer {
std:: string name;
int accountNumber;
double balance;
}
//Banking logic
std:: vector<Customer>customers;
//Callback functions
void depositCallback(FI/ Widget* widget, void* input){
FI_ input* accountInput=
static_ cast <FI _input*>( input);
int accountNumber =
std:: atoi(accountInput-> value());
for(auto & customer: customers){
if (customer.accountNumber==accountNumber){
customer.balance += 100;
//example
Add $100;
break;
}
}
}
int main (){
// Generate random customer data.
for( int i=0; i< 40; ++i){
customer.push_back({"Customers" + std:: to_string (i+1) ,1000 +i,rand()% 10000})
}
//Create GUI window
FI_Window window (500,400 "Banking System");
// Account number input.
FI_Input accountInput (200,50,200,30, " Account Number:");
//Deposit button
FI_ Button depositButton(200,100,100,30, " Deposit");
depositButton.callba
ck(deposit callback, &
accountInput);
Window.show();
returnFI:: run ();
}
Now integrate banking logic file handling: You can use file I/O to save and load data of customers.
Functions: Link buttons to deposit money, withdraw money and balance inquiry.
Display results.
FI_ outs or FI_ box widgets can be used to display messages and data.
Testing..
Make sure every function works correctly.
So that was it. Just try to practice and it won't seem as complex as it might seem for the first time. Build something amazing!
Comments
Post a Comment