diff --git a/Main.txt b/Main.txt new file mode 100644 index 0000000..6744e2d --- /dev/null +++ b/Main.txt @@ -0,0 +1,325 @@ +#include +#include "motor.h" +#include +using namespace std; + +int main() +{ + int a,c; + list_pelanggan L1; + list_Motorcycle L2; + list_terbanyak1 L3; + createList_pelanggan(L1); + createList_Motorcycle(L2); + createList_terbanyak1(L3); + menu(); + cout << "Choose : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + + do + { + if ( a == 1 ) + { + system("cls"); + infotype_pelanggan x; + adr_pelanggan P; + cout << "==Input Customer ID==" << endl; + cout << "Customer ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; + cin >> c; + } + x.id_pelanggan = c; + cout << "Nam3 : "; + cin >> x.nama; + cout << "No. Hp : "; + cin >> x.hp; + cout << endl; + P = alokasi_pelanggan(x); + insert_pelanggan(L1,P); + system("cls"); + cout << "Customer Data with Name : "; + cout << info(P).nama; + cout << "Input data Success"; + cout << endl; + menu(); + cout << "Choose Menu : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; + cin >> c; + } + a = c; + } + else if ( a == 2 ) + { + system("cls"); + infotype_Motorcycle x; + adr_Motorcycle P; + cout << "==Input Motorcycle Data==" << endl; + cout << "Motorcycle ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_Motorcycle = c; + cout << "Motorcycle Brand : "; + cin >> x.merek; + cout << "Production Year : "; + cin >> x.tahun; + P = alokasi_Motorcycle(x); + insert_Motorcycle(L2,P); + system("cls"); + cout << "Motorcycle data with Brand"; + cout << x.merek; + cout << "Success to be Inputed"; + cout << endl; + menu(); + cout << "Choose menu : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 3 ) + { + system("cls"); + infotype_history x; + int id_Motorcycle, z; + cout << "==Input Tenant Data==" << endl; + cout << "Tenant ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + z = c; + cout << "Tenant ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_history = c; + cout << "Motorcycle ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id_Motorcycle = c; + cout << "Rent Date : "; cin >> x.date; + cout << "how long tenant will rent the Motorcycle : "; cin >> x.lama; + insert_history(L1,L2,x,id_Motorcycle,z); + system("cls"); + cout << "Tenants Data with Tenant ID : "; cout << x.id_history; cout << " Success to be Inputed"; + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 4 ) + { + system("cls"); + int id; + cout << "==Delete Customer Data==" << endl; + cout << "Input ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + delete_pelanggan(L1,id); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 5 ) + { + system("cls"); + int id; + cout << "==Delete Motorcycle Data==" << endl; + cout << "Input Motorcycle ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + delete_Motorcycle(L2,id); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 6 ) + { + system("cls"); + int id, id_history; + cout << "==Delete Tenant Data==" << endl; + cout << "Input Tenant ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + cout << "Input History ID that will be deleted :"; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id_history = c; + delete_history(L1,id,id_history); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 7 ) + { + system("cls"); + infotype_pelanggan x; adr_pelanggan Q; + cout << "==Update Customer Data==" << endl; + cout << "Customer ID : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_pelanggan = c; + cout << "=Input New Data=" << endl; + cout << "Name : "; cin >> x.nama; + cout << "No. Hp : "; cin >> x.hp; + Q = alokasi_pelanggan(x); + update(L1,Q); + system("cls"); + cout << "Update Process Finished"; + cout << endl; + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 8 ) + { + system("cls"); + view_pelanggan(L1); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 9 ) + { + system("cls"); + view_Motorcycle(L2); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 10 ) + { + system("cls"); + cout << "==Find Customer Data=="; cout << endl; + int x; cout << "Input ID : "; + cin >> x; + cout << endl; + Motorcyclei(L1,x); + cout << endl; + cout << "Find Process Finished"; cout << endl; + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 11 ) + { + system("cls"); + cout << "==Customer that often rent Motorcycle==" << endl; + cout << endl; + report(L1,L3); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 12 ) + { + system("cls"); + view_motorpelanggan(L1); + menu(); + cout << endl; + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 13 ) + { + system("cls"); + view_pelangganmotor(L1,L2); + menu(); + cout << endl; + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else + { + cout << "Menu Input is False, Input Again : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + } + while ( a != 0); +} diff --git a/bin/Debug/tubes.exe b/bin/Debug/tubes.exe new file mode 100644 index 0000000..ef57852 Binary files /dev/null and b/bin/Debug/tubes.exe differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..16f3695 --- /dev/null +++ b/main.cpp @@ -0,0 +1,325 @@ +#include +#include "mobil.h" +#include +using namespace std; + +int main() +{ + int a,c; + list_pelanggan L1; + list_car L2; + list_terbanyak1 L3; + createList_pelanggan(L1); + createList_car(L2); + createList_terbanyak1(L3); + menu(); + cout << "Choose : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + + do + { + if ( a == 1 ) + { + system("cls"); + infotype_pelanggan x; + adr_pelanggan P; + cout << "==Input Customer ID==" << endl; + cout << "Customer ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; + cin >> c; + } + x.id_pelanggan = c; + cout << "Nam3 : "; + cin >> x.nama; + cout << "No. Hp : "; + cin >> x.hp; + cout << endl; + P = alokasi_pelanggan(x); + insert_pelanggan(L1,P); + system("cls"); + cout << "Customer Data with Name : "; + cout << info(P).nama; + cout << "Input data Success"; + cout << endl; + menu(); + cout << "Choose Menu : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; + cin >> c; + } + a = c; + } + else if ( a == 2 ) + { + system("cls"); + infotype_car x; + adr_car P; + cout << "==Input Car Data==" << endl; + cout << "Car ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_car = c; + cout << "Car Brand : "; + cin >> x.merek; + cout << "Production Year : "; + cin >> x.tahun; + P = alokasi_car(x); + insert_car(L2,P); + system("cls"); + cout << "Car data with Brand"; + cout << x.merek; + cout << "Success to be Inputed"; + cout << endl; + menu(); + cout << "Choose menu : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 3 ) + { + system("cls"); + infotype_history x; + int id_car, z; + cout << "==Input Tenant Data==" << endl; + cout << "Tenant ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + z = c; + cout << "Tenant ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_history = c; + cout << "Car ID : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id_car = c; + cout << "Rent Date : "; cin >> x.date; + cout << "how long tenant will rent the car : "; cin >> x.lama; + insert_history(L1,L2,x,id_car,z); + system("cls"); + cout << "Tenants Data with Tenant ID : "; cout << x.id_history; cout << " Success to be Inputed"; + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 4 ) + { + system("cls"); + int id; + cout << "==Delete Customer Data==" << endl; + cout << "Input ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + delete_pelanggan(L1,id); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 5 ) + { + system("cls"); + int id; + cout << "==Delete Car Data==" << endl; + cout << "Input Car ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + delete_car(L2,id); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 6 ) + { + system("cls"); + int id, id_history; + cout << "==Delete Tenant Data==" << endl; + cout << "Input Tenant ID that will be deleted : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id = c; + cout << "Input History ID that will be deleted :"; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + id_history = c; + delete_history(L1,id,id_history); + cout << endl; + menu(); + cout << "Choose menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 7 ) + { + system("cls"); + infotype_pelanggan x; adr_pelanggan Q; + cout << "==Update Customer Data==" << endl; + cout << "Customer ID : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + x.id_pelanggan = c; + cout << "=Input New Data=" << endl; + cout << "Name : "; cin >> x.nama; + cout << "No. Hp : "; cin >> x.hp; + Q = alokasi_pelanggan(x); + update(L1,Q); + system("cls"); + cout << "Update Process Finished"; + cout << endl; + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 8 ) + { + system("cls"); + view_pelanggan(L1); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 9 ) + { + system("cls"); + view_car(L2); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 10 ) + { + system("cls"); + cout << "==Find Customer Data=="; cout << endl; + int x; cout << "Input ID : "; + cin >> x; + cout << endl; + cari(L1,x); + cout << endl; + cout << "Find Process Finished"; cout << endl; + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 11 ) + { + system("cls"); + cout << "==Customer that often rent car==" << endl; + cout << endl; + report(L1,L3); + menu(); + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 12 ) + { + system("cls"); + view_mobilpelanggan(L1); + menu(); + cout << endl; + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else if ( a == 13 ) + { + system("cls"); + view_pelangganmobil(L1,L2); + menu(); + cout << endl; + cout << "Choose Menu : "; cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + else + { + cout << "Menu Input is False, Input Again : "; + cin >> c; + while ( !isInteger(c) ) + { + cout << "Wrong Format, Fill Again : "; cin >> c; + } + a = c; + } + } + while ( a != 0); +} diff --git a/mobil.cpp b/mobil.cpp new file mode 100644 index 0000000..3c18519 --- /dev/null +++ b/mobil.cpp @@ -0,0 +1,775 @@ +#include +#include "mobil.h" +#include + +using namespace std; + + +adr_pelanggan alokasi_pelanggan (infotype_pelanggan x) //alokasi parent / entitas 1 +{ + adr_pelanggan Q; + Q = new elm_pelanggan; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + first_history(Q) = NULL; + last_history(Q) = NULL; + return Q; +} + +adr_car alokasi_car (infotype_car x) //alokasi entitas 2 +{ + adr_car Q; + Q = new elm_car; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + return Q; +} + +adr_history alokasi_history (infotype_history x) //alokasi child +{ + adr_history Q; + Q = new elm_history; + info(Q) = x; + next(Q) = NULL; + car(Q) = NULL; + return Q; +} + +adr_terbanyak1 alokasi_terbanyak1 (infotype_terbanyak1 x) //alokasi list report +{ + adr_terbanyak1 Q; + Q = new elm_terbanyak1; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + return Q; +} + +//adr_terbanyak2 alokasi_terbanyak2 (int x) +//{ +// adr_terbanyak2 Q; +// Q = new elm_terbanyak2; +// info(Q) = x; +// next(Q) = NULL; +// prev(Q) = NULL; +// return Q; +//} + +bool isEmpty_pelanggan (list_pelanggan L) //cek list pelanggan +{ + if ((first(L) == NULL) && (last(L) == NULL) ) + return true; + else + return false; +} + +bool isEmpty_car (list_car L) //cek list mobil +{ + if ((first(L) == NULL) && (last(L) == NULL) ) + return true; + else + return false; +} + +bool isInteger(int x) //validasi integer +{ + if ( !cin ) + { + cin.clear(); + cin.ignore(); + return false; + } + else + return true; +} + +void menu () +{ + cout << endl; + cout << "================================Tenant Car================================" << endl; + cout << "Menu:" < info(Q).id_pelanggan ) + { + next(Q) = P; + prev(P) = Q; + first(L) = Q; + } + + else if ( info(P).id_pelanggan < info(Q).id_pelanggan ) + { + if ( next(P) == NULL ) + { + next(P) = Q; + prev(Q) = P; + next(Q) = NULL; + last(L) = Q; + } + + else + { + while ( (next(P) != NULL) && (info(P).id_pelanggan < info(Q).id_pelanggan) ) + { + P = next(P); + } + if ( (next(P) == NULL) && (info(P).id_pelanggan < info(Q).id_pelanggan) ) + { + next(P) = Q; + prev(Q) = P; + last(L) = Q; + } + + else if ( info(P).id_pelanggan == info(Q).id_pelanggan ) + { + cout << "The ID is Exist"; + } + + else + { + prev(Q) = prev(P); + next(prev(P)) = Q; + prev(P) = Q; + next(Q) = P; + } + } + } + + else + { + cout << "The ID and Data is already used"; + } + } + + else + { + next(Q) = NULL; + prev(Q) = NULL; + first(L) = Q; + last(L) = Q; + } +} + +void insert_car (list_car &L, adr_car Q) //insert mobil (insert first) +{ + adr_car P; + P = first(L); + + if (!isEmpty_car(L)) + { + next(Q) = P; + prev(P) = Q; + first(L) = Q; + } + + else + { + first(L) = Q; + last(L) = Q; + } +} + +void insert_history (list_pelanggan &L, list_car L2, infotype_history x, int id_car, int id) //insert history (insert last) +{ + adr_pelanggan P; + P = first(L); + adr_car R; + R = first(L2); + adr_history Q; + Q = alokasi_history(x); + bool found; + found = false; + + while ( P != NULL ) + { + if ( info(P).id_pelanggan == id ) + { + while ( ( info(R).id_car != id_car ) && ( next(R) != NULL ) ) + { + R = next(R); + } + if ( info(R).id_car == id_car ) + { + car(Q) = R; + } + if ( first_history(P) == NULL ) + { + first_history(P) = Q; + last_history(P) = Q; + } + else + { + next(last_history(P)) = Q; + last_history(P) = Q; + } + found = true; + } + P = next(P); + } + if ( ( found == false ) && ( next(P) == NULL ) ) + { + cout << "Customer Data Not Found"; + } +} + +void delete_pelanggan (list_pelanggan &L, int id) +{ + adr_pelanggan P,Q,R; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == id ) + { + if ( ( prev(P) != NULL ) && ( next(P) != NULL ) ) + { + Q = prev(P); R = next(P); + next(Q) = R; + prev(R) = Q; + next(P) = NULL; + prev(P) = NULL; + } + else if ( ( prev(P) == NULL ) && ( next(P) == NULL ) ) + { + first(L) = NULL; + last(L) = NULL; + } + else if ( prev(P) == NULL ) + { + first(L) = next(P); + prev(next(P)) = NULL; + next(P) = NULL; + } + else if ( next(P) == NULL ) + { + last(L) = prev(P); + next(prev(P)) = NULL; + prev(P) = NULL; + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "The data is empty or already deleted"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void delete_car (list_car &L, int id) +{ + adr_car P,Q,R; + P = first(L); + + if ( !isEmpty_car(L) ) + { + while ( ( info(P).id_car != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_car == id ) + { + if ( ( prev(P) != NULL ) && ( next(P) != NULL ) ) + { + Q = prev(P); R = next(P); + next(Q) = R; + prev(R) = Q; + next(P) = NULL; + prev(P) = NULL; + } + else if ( ( prev(P) == NULL ) && ( next(P) == NULL ) ) + { + first(L) = NULL; + last(L) = NULL; + } + else if ( prev(P) == NULL ) + { + first(L) = next(P); + prev(next(P)) = NULL; + next(P) = NULL; + } + else if ( next(P) == NULL ) + { + last(L) = prev(P); + next(prev(P)) = NULL; + prev(P) = NULL; + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "The data is empty or already deleted"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void delete_history (list_pelanggan &L, int id, int id_history) +{ + adr_pelanggan P; + P = first(L); + adr_history Q,R; + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == id ) + { + if ( first_history(P) != NULL ) + { + Q = first_history(P); + while ( ( info(Q).id_history != id_history ) && ( next(Q) != NULL ) ) + { + R = Q; + Q = next(Q); + } + if ( info(Q).id_history == id_history ) + { + if ( first_history(P) == Q ) + { + first_history(P) = next(Q); + next(Q) = NULL; + } + else if ( next(Q) == NULL ) + { + last_history(P) = R; + } + else + { + next(R) = next(Q); + next(Q) = NULL; + } + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "Tenant data is Empty"; + } + } + else + { + cout << endl; + cout << "Customer Data NOT FOUND"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void update (list_pelanggan &L, adr_pelanggan Q) +{ + adr_pelanggan P; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != info(Q).id_pelanggan ) && ( P != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == info(Q).id_pelanggan ) + { + info(P) = info(Q); + } + else + { + cout << "Data NOT FOUND"; + } + } + else + { + cout << "Empty List"; + } +} + + +void view_pelanggan (list_pelanggan L) +{ + adr_pelanggan P; + P = first(L); + if ( P != NULL ) + { + cout << "==Customer data that already inputed=="; + cout << endl; + cout << endl; + while ( next(P) != NULL ) + { + cout << "Name :"; + cout << info(P).nama; cout << endl; + cout << "ID :"; + cout << info(P).id_pelanggan; cout << endl; + cout << "No. Hp :"; + cout << info(P).hp; cout << endl; + cout << endl; + P = next(P); + } + cout << "Name :"; + cout << info(P).nama; cout << endl; + cout << "ID :"; + cout << info(P).id_pelanggan; cout << endl; + cout << "No. Hp :"; + cout << info(P).hp; cout << endl; + cout << endl; + } + else + { + cout << "Empty List"; + } +} + +void view_car (list_car L) +{ + adr_car P; + P = first(L); + infotype_car x; + + if ( !isEmpty_car(L) ) + { + cout << "==Car Data that already inputed=="; + cout << endl; + cout << endl; + while ( next(P) != NULL ) + { + cout << "The Brand of The Car : "; + cout << info(P).merek; cout << endl; + cout << "Production Year : "; + cout << info(P).tahun; cout << endl; + cout << "Car ID : "; + cout << info(P).id_car; cout << endl; + cout << endl; + P = next(P); + } + cout << "The Brand of The Car : "; + cout << info(P).merek; cout << endl; + cout << "Production Year : "; + cout << info(P).tahun; cout << endl; + cout << "Car ID : "; + cout << info(P).id_car; cout << endl; + cout << endl; + } + else + { + cout << "Empty List"; + } +} + +void view_mobilpelanggan (list_pelanggan L) +{//clear + adr_pelanggan P; + adr_history Q; + adr_car R; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + cout << "==Data pelanggan dan mobil yang di sewa=="; + cout << endl; cout << endl; + while ( P != NULL ) + { + if ( first_history(P) != NULL ) + { + cout << endl; + cout << "Customer Data : " << endl; + cout << "Name : "; cout << info(P).nama << endl; + cout << "ID : "; cout << info(P).id_pelanggan << endl; + cout << "No.Hp: "; cout << info(P).hp << endl; + cout << endl; + cout << "The car that rented : " << endl; cout << endl; + Q = first_history(P); + + while ( Q != NULL ) + { + R = car(Q); + cout << "Brand : "; cout << info(R).merek << endl; + cout << "Car ID : "; cout << info(R).id_car << endl; + cout << endl; + Q = next(Q); + + } + } + else + { + cout << endl; + cout << "Customer Data : " << endl; + cout << "Name : "; cout << info(P).nama << endl; + cout << "ID : "; cout << info(P).id_pelanggan << endl; + cout << "No.Hp: "; cout << info(P).hp << endl; + cout << endl; + cout << "The rented car that not returned yet : "; + cout << endl; cout << endl; + } + cout << "========================================"; + cout << endl; cout << endl; + P = next(P); + } + } + else + { + cout << "Customer List is Empty"; + cout << endl; + } +} + +void view_pelangganmobil (list_pelanggan L, list_car L2) +{ + adr_pelanggan P; + adr_car Q,S; + adr_history R,T; + Q = first(L2); + infotype_history x; + infotype_pelanggan y; + + while ( Q != NULL ) + { + cout << "==Car Data=="; cout << endl; + cout << "The Brand of The Car : "; cout << info(Q).merek; cout << endl; + cout << "Production Year : "; cout << info(Q).tahun; cout << endl; + cout << "Car ID : "; cout << info(Q).id_car; cout << endl; + cout << endl; + cout << "This Car is Rented by : "<next +#define prev(P) P->prev +#define info(P) P->info +#define car(P) P->car +#define first_history(P) P->first_history +#define last_history(P) P->last_history + +#define first(L) L.first +#define last(L) L.last + +using namespace std; + +typedef struct elm_car *adr_car; +typedef struct elm_history *adr_history; +typedef struct elm_pelanggan *adr_pelanggan; +typedef struct elm_terbanyak1 *adr_terbanyak1; +typedef struct elm_terbanyak2 *adr_terbanyak2; + +struct infotype_pelanggan +{ + int id_pelanggan; + string nama; + string hp; +}; + +struct elm_pelanggan +{ + infotype_pelanggan info; + adr_pelanggan next; + adr_pelanggan prev; + adr_history first_history; + adr_history last_history; +}; + +struct infotype_history +{ + int id_history; + string date; + string lama; +}; + +struct elm_history +{ + infotype_history info; + adr_history next; + adr_car car; +}; + +struct infotype_car +{ + string merek; + string tahun; + int id_car; +}; + +struct elm_car +{ + infotype_car info; + adr_car next; + adr_car prev; +}; + +struct infotype_terbanyak1 +{ + int id_pelanggan,jumlah; + string nama; +}; + +struct elm_terbanyak1 +{ + infotype_terbanyak1 info; + adr_terbanyak1 next; + adr_terbanyak1 prev; +}; + +//struct elm_terbanyak2 +//{ +// int info; +// adr_terbanyak2 next; +// adr_terbanyak2 prev; +//}; + +struct list_pelanggan +{ + adr_pelanggan first; + adr_pelanggan last; +}; + +struct list_car +{ + adr_car first; + adr_car last; +}; + +struct list_terbanyak1 +{ + adr_terbanyak1 first; + adr_terbanyak1 last; +}; + +//struct list_terbanyak2 +//{ +// adr_terbanyak2 first; +// adr_terbanyak2 last; +//}; + + +adr_pelanggan alokasi_pelanggan (infotype_pelanggan x); +adr_car alokasi_car (infotype_car x); +adr_terbanyak1 alokasi_terbanyak1 (int x); +adr_terbanyak2 alokasi_terbanyak2 (int x); +bool isInteger(int x); +void menu(); +void createList_pelanggan (list_pelanggan &L); +void createList_car (list_car &L); +void createList_terbanyak1 (list_terbanyak1 &L); +//void createList_terbanyak2 (list_terbanyak2 &L); +void insert_pelanggan (list_pelanggan &L, adr_pelanggan Q); +void insert_car (list_car &L, adr_car Q); +void insert_history (list_pelanggan &L, list_car L2, infotype_history x, int id_car, int id); +void delete_pelanggan (list_pelanggan &L, int id); +void delete_car (list_car &L, int id); +void delete_history (list_pelanggan &L, int id, int id_history); +void update (list_pelanggan &L, adr_pelanggan Q); +void view_pelanggan (list_pelanggan L); +void view_car (list_car L); +void view_mobilpelanggan (list_pelanggan L); +void view_pelangganmobil (list_pelanggan L, list_car L2); +void cari (list_pelanggan L, int x); +void report (list_pelanggan L, list_terbanyak1 &L2); + +#endif // MOBIL_H_INCLUDED diff --git a/motor.cpp b/motor.cpp new file mode 100644 index 0000000..e6516d3 --- /dev/null +++ b/motor.cpp @@ -0,0 +1,775 @@ +#include +#include "motor.h" +#include + +using namespace std; + + +adr_pelanggan alokasi_pelanggan (infotype_pelanggan x) //alokasi parent / entitas 1 +{ + adr_pelanggan Q; + Q = new elm_pelanggan; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + first_history(Q) = NULL; + last_history(Q) = NULL; + return Q; +} + +adr_Motorcycle alokasi_Motorcycle (infotype_Motorcycle x) //alokasi entitas 2 +{ + adr_Motorcycle Q; + Q = new elm_Motorcycle; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + return Q; +} + +adr_history alokasi_history (infotype_history x) //alokasi child +{ + adr_history Q; + Q = new elm_history; + info(Q) = x; + next(Q) = NULL; + Motorcycle(Q) = NULL; + return Q; +} + +adr_terbanyak1 alokasi_terbanyak1 (infotype_terbanyak1 x) //alokasi list report +{ + adr_terbanyak1 Q; + Q = new elm_terbanyak1; + info(Q) = x; + next(Q) = NULL; + prev(Q) = NULL; + return Q; +} + +//adr_terbanyak2 alokasi_terbanyak2 (int x) +//{ +// adr_terbanyak2 Q; +// Q = new elm_terbanyak2; +// info(Q) = x; +// next(Q) = NULL; +// prev(Q) = NULL; +// return Q; +//} + +bool isEmpty_pelanggan (list_pelanggan L) //cek list pelanggan +{ + if ((first(L) == NULL) && (last(L) == NULL) ) + return true; + else + return false; +} + +bool isEmpty_Motorcycle (list_Motorcycle L) //cek list motor +{ + if ((first(L) == NULL) && (last(L) == NULL) ) + return true; + else + return false; +} + +bool isInteger(int x) //validasi integer +{ + if ( !cin ) + { + cin.clear(); + cin.ignore(); + return false; + } + else + return true; +} + +void menu () +{ + cout << endl; + cout << "================================Tenant Motorcycle================================" << endl; + cout << "Menu:" < info(Q).id_pelanggan ) + { + next(Q) = P; + prev(P) = Q; + first(L) = Q; + } + + else if ( info(P).id_pelanggan < info(Q).id_pelanggan ) + { + if ( next(P) == NULL ) + { + next(P) = Q; + prev(Q) = P; + next(Q) = NULL; + last(L) = Q; + } + + else + { + while ( (next(P) != NULL) && (info(P).id_pelanggan < info(Q).id_pelanggan) ) + { + P = next(P); + } + if ( (next(P) == NULL) && (info(P).id_pelanggan < info(Q).id_pelanggan) ) + { + next(P) = Q; + prev(Q) = P; + last(L) = Q; + } + + else if ( info(P).id_pelanggan == info(Q).id_pelanggan ) + { + cout << "The ID is Exist"; + } + + else + { + prev(Q) = prev(P); + next(prev(P)) = Q; + prev(P) = Q; + next(Q) = P; + } + } + } + + else + { + cout << "The ID and Data is already used"; + } + } + + else + { + next(Q) = NULL; + prev(Q) = NULL; + first(L) = Q; + last(L) = Q; + } +} + +void insert_Motorcycle (list_Motorcycle &L, adr_Motorcycle Q) //insert motor (insert first) +{ + adr_Motorcycle P; + P = first(L); + + if (!isEmpty_Motorcycle(L)) + { + next(Q) = P; + prev(P) = Q; + first(L) = Q; + } + + else + { + first(L) = Q; + last(L) = Q; + } +} + +void insert_history (list_pelanggan &L, list_Motorcycle L2, infotype_history x, int id_Motorcycle, int id) //insert history (insert last) +{ + adr_pelanggan P; + P = first(L); + adr_Motorcycle R; + R = first(L2); + adr_history Q; + Q = alokasi_history(x); + bool found; + found = false; + + while ( P != NULL ) + { + if ( info(P).id_pelanggan == id ) + { + while ( ( info(R).id_Motorcycle != id_Motorcycle ) && ( next(R) != NULL ) ) + { + R = next(R); + } + if ( info(R).id_Motorcycle == id_Motorcycle ) + { + Motorcycle(Q) = R; + } + if ( first_history(P) == NULL ) + { + first_history(P) = Q; + last_history(P) = Q; + } + else + { + next(last_history(P)) = Q; + last_history(P) = Q; + } + found = true; + } + P = next(P); + } + if ( ( found == false ) && ( next(P) == NULL ) ) + { + cout << "Customer Data Not Found"; + } +} + +void delete_pelanggan (list_pelanggan &L, int id) +{ + adr_pelanggan P,Q,R; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == id ) + { + if ( ( prev(P) != NULL ) && ( next(P) != NULL ) ) + { + Q = prev(P); R = next(P); + next(Q) = R; + prev(R) = Q; + next(P) = NULL; + prev(P) = NULL; + } + else if ( ( prev(P) == NULL ) && ( next(P) == NULL ) ) + { + first(L) = NULL; + last(L) = NULL; + } + else if ( prev(P) == NULL ) + { + first(L) = next(P); + prev(next(P)) = NULL; + next(P) = NULL; + } + else if ( next(P) == NULL ) + { + last(L) = prev(P); + next(prev(P)) = NULL; + prev(P) = NULL; + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "The data is empty or already deleted"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void delete_Motorcycle (list_Motorcycle &L, int id) +{ + adr_Motorcycle P,Q,R; + P = first(L); + + if ( !isEmpty_Motorcycle(L) ) + { + while ( ( info(P).id_Motorcycle != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_Motorcycle == id ) + { + if ( ( prev(P) != NULL ) && ( next(P) != NULL ) ) + { + Q = prev(P); R = next(P); + next(Q) = R; + prev(R) = Q; + next(P) = NULL; + prev(P) = NULL; + } + else if ( ( prev(P) == NULL ) && ( next(P) == NULL ) ) + { + first(L) = NULL; + last(L) = NULL; + } + else if ( prev(P) == NULL ) + { + first(L) = next(P); + prev(next(P)) = NULL; + next(P) = NULL; + } + else if ( next(P) == NULL ) + { + last(L) = prev(P); + next(prev(P)) = NULL; + prev(P) = NULL; + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "The data is empty or already deleted"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void delete_history (list_pelanggan &L, int id, int id_history) +{ + adr_pelanggan P; + P = first(L); + adr_history Q,R; + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != id ) && ( next(P) != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == id ) + { + if ( first_history(P) != NULL ) + { + Q = first_history(P); + while ( ( info(Q).id_history != id_history ) && ( next(Q) != NULL ) ) + { + R = Q; + Q = next(Q); + } + if ( info(Q).id_history == id_history ) + { + if ( first_history(P) == Q ) + { + first_history(P) = next(Q); + next(Q) = NULL; + } + else if ( next(Q) == NULL ) + { + last_history(P) = R; + } + else + { + next(R) = next(Q); + next(Q) = NULL; + } + } + cout << endl; + cout << "Delete Process is Done"; + } + else + { + cout << endl; + cout << "Tenant data is Empty"; + } + } + else + { + cout << endl; + cout << "Customer Data NOT FOUND"; + } + } + else + { + cout << endl; + cout << "Empty List"; + } +} + +void update (list_pelanggan &L, adr_pelanggan Q) +{ + adr_pelanggan P; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + while ( ( info(P).id_pelanggan != info(Q).id_pelanggan ) && ( P != NULL ) ) + { + P = next(P); + } + if ( info(P).id_pelanggan == info(Q).id_pelanggan ) + { + info(P) = info(Q); + } + else + { + cout << "Data NOT FOUND"; + } + } + else + { + cout << "Empty List"; + } +} + + +void view_pelanggan (list_pelanggan L) +{ + adr_pelanggan P; + P = first(L); + if ( P != NULL ) + { + cout << "==Customer data that already inputed=="; + cout << endl; + cout << endl; + while ( next(P) != NULL ) + { + cout << "Name :"; + cout << info(P).nama; cout << endl; + cout << "ID :"; + cout << info(P).id_pelanggan; cout << endl; + cout << "No. Hp :"; + cout << info(P).hp; cout << endl; + cout << endl; + P = next(P); + } + cout << "Name :"; + cout << info(P).nama; cout << endl; + cout << "ID :"; + cout << info(P).id_pelanggan; cout << endl; + cout << "No. Hp :"; + cout << info(P).hp; cout << endl; + cout << endl; + } + else + { + cout << "Empty List"; + } +} + +void view_Motorcycle (list_Motorcycle L) +{ + adr_Motorcycle P; + P = first(L); + infotype_Motorcycle x; + + if ( !isEmpty_Motorcycle(L) ) + { + cout << "==Motorcycle Data that already inputed=="; + cout << endl; + cout << endl; + while ( next(P) != NULL ) + { + cout << "The Brand of The Motorcycle : "; + cout << info(P).merek; cout << endl; + cout << "Production Year : "; + cout << info(P).tahun; cout << endl; + cout << "Motorcycle ID : "; + cout << info(P).id_Motorcycle; cout << endl; + cout << endl; + P = next(P); + } + cout << "The Brand of The Motorcycle : "; + cout << info(P).merek; cout << endl; + cout << "Production Year : "; + cout << info(P).tahun; cout << endl; + cout << "Motorcycle ID : "; + cout << info(P).id_Motorcycle; cout << endl; + cout << endl; + } + else + { + cout << "Empty List"; + } +} + +void view_motorpelanggan (list_pelanggan L) +{//clear + adr_pelanggan P; + adr_history Q; + adr_Motorcycle R; + P = first(L); + + if ( !isEmpty_pelanggan(L) ) + { + cout << "==Data pelanggan dan motor yang di sewa=="; + cout << endl; cout << endl; + while ( P != NULL ) + { + if ( first_history(P) != NULL ) + { + cout << endl; + cout << "Customer Data : " << endl; + cout << "Name : "; cout << info(P).nama << endl; + cout << "ID : "; cout << info(P).id_pelanggan << endl; + cout << "No.Hp: "; cout << info(P).hp << endl; + cout << endl; + cout << "The Motorcycle that rented : " << endl; cout << endl; + Q = first_history(P); + + while ( Q != NULL ) + { + R = Motorcycle(Q); + cout << "Brand : "; cout << info(R).merek << endl; + cout << "Motorcycle ID : "; cout << info(R).id_Motorcycle << endl; + cout << endl; + Q = next(Q); + + } + } + else + { + cout << endl; + cout << "Customer Data : " << endl; + cout << "Name : "; cout << info(P).nama << endl; + cout << "ID : "; cout << info(P).id_pelanggan << endl; + cout << "No.Hp: "; cout << info(P).hp << endl; + cout << endl; + cout << "The rented Motorcycle that not returned yet : "; + cout << endl; cout << endl; + } + cout << "========================================"; + cout << endl; cout << endl; + P = next(P); + } + } + else + { + cout << "Customer List is Empty"; + cout << endl; + } +} + +void view_pelangganmotor (list_pelanggan L, list_Motorcycle L2) +{ + adr_pelanggan P; + adr_Motorcycle Q,S; + adr_history R,T; + Q = first(L2); + infotype_history x; + infotype_pelanggan y; + + while ( Q != NULL ) + { + cout << "==Motorcycle Data=="; cout << endl; + cout << "The Brand of The Motorcycle : "; cout << info(Q).merek; cout << endl; + cout << "Production Year : "; cout << info(Q).tahun; cout << endl; + cout << "Motorcycle ID : "; cout << info(Q).id_Motorcycle; cout << endl; + cout << endl; + cout << "This Motorcycle is Rented by : "< + + + + + diff --git a/tubes.depend b/tubes.depend new file mode 100644 index 0000000..d2b5706 --- /dev/null +++ b/tubes.depend @@ -0,0 +1,35 @@ +# depslib dependency file v1.0 +1480148424 source:d:\tubes asd\30 oct 16\tubes\main.cpp + + "mobil.h" + +1480149526 source:d:\tubes asd\30 oct 16\tubes\mobil.cpp + + "mobil.h" + +1480147751 d:\tubes asd\30 oct 16\tubes\mobil.h + +1480521553 source:d:\tubes asd\26 nov 16\tubes\main.cpp + + "mobil.h" + + +1480521522 d:\tubes asd\26 nov 16\tubes\mobil.h + +1480521482 source:d:\tubes asd\26 nov 16\tubes\mobil.cpp + + "mobil.h" + + +1524915575 source:f:\perkuliahan\tugas\asd-adf\tubes\main.cpp + + "mobil.h" + + +1480521522 f:\perkuliahan\tugas\asd-adf\tubes\mobil.h + +1524917146 source:f:\perkuliahan\tugas\asd-adf\tubes\mobil.cpp + + "mobil.h" + + diff --git a/tubes/.gitattributes b/tubes/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/tubes/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto