Anda di halaman 1dari 7

LAPORAN TUGAS BESAR STRUKTUR DATA

SISTEM PENDATAAN MAHASISWA DAN DOSEN WALI

Disusun oleh:
Kelompok 1

Muhammad Irhaz Adha A. Basyah - 1301218708


Desi Dwi Purwasih - 1304212095

INFORMATIKA
FAKULTAS INFORMATIKA
TELKOM UNIVERSITY
BANDUNG
2023
Deskripsi : Manajemen perwalian merupakan konsultasi mahasiswa kepada
dosen wali, baik dalam bidang akademik maupun non-akademik untuk menunjang
keberhasilan studi dan perkembangan mahasiswa. Bagian terpenting dari proses
setiap mahasiswa mempunyai dosen wali yang bertugas memberikan bimbingan
dalam bidang akademik dan bidang terkait kepada mahasiswa. Pembinaandan
bimbingan ini umumnya diberikan dalam bentuk perwalian. Bagian penting dari
perwalian adalah memberikan saran dan informasi akademik termasuk informasi
mengenai peraturan dan prosedur akademik terkait dengan kemajuan studi masing-
masing individu mahasiswa

Berikut adalah kode program yang kami kerjakan pada tugas besar
struktur data
➔ Tipe MLL
mylist.h

// mylist.h
#ifndef MYLIST_H
#define MYLIST_H

#include <iostream>
#include <string>

using namespace std;

struct CollegeStudentInfo {
string name;
string nim;
double ipk;
};

struct Node {
CollegeStudentInfo data;
Node* next;
};

typedef Node* Address;

struct List {
Address first;
};

void createList(List& list);


Address newElement(const CollegeStudentInfo& collegeStudent);
void insertFirst(List& list, Address pointer);
void insertLast(List& list, Address pointer);
void deleteFirst(List& list, Address& pointer);
void deleteLast(List& list, Address& pointer);
void deleteAllAndOutputElement(List& list, int condition);
void printList(const List& list);

#endif // MYLIST_H

mylist.cpp

// mylist.cpp
#include "mylist.h"

void createList(List& list) {


list.first = nullptr;
}

Address newElement(const CollegeStudentInfo& collegeStudent) {


Address newNode = new Node;
newNode->data = collegeStudent;
newNode->next = nullptr;
return newNode;
}

void insertFirst(List& list, Address pointer) {


pointer->next = list.first;
list.first = pointer;
}

void insertLast(List& list, Address pointer) {


if (list.first == nullptr) {
list.first = pointer;
} else {
Address last = list.first;
while (last->next != nullptr) {
last = last->next;
}
last->next = pointer;
}
}

void deleteFirst(List& list, Address& pointer) {


if (list.first != nullptr) {
pointer = list.first;
list.first = list.first->next;
delete pointer;
}
}

void deleteLast(List& list, Address& pointer) {


if (list.first != nullptr) {
if (list.first->next == nullptr) {
pointer = list.first;
list.first = nullptr;
} else {
Address prev = nullptr;
Address current = list.first;
while (current->next != nullptr) {
prev = current;
current = current->next;
}
pointer = current;
prev->next = nullptr;
}
delete pointer;
}
}

void deleteAllAndOutputElement(List& list, int condition) {


Address current = list.first;
while (current != nullptr) {
Address next = current->next;
// Output or delete based on condition
if (condition == 0) {
cout << "Deleted: " << current->data.name << " - "
<< current->data.nim << " - " << current->data.ipk << endl;
delete current;
} else {
// Output or delete based on other condition
}
current = next;
}
list.first = nullptr;
}

void printList(const List& list) {


Address current = list.first;
while (current != nullptr) {
cout << current->data.name << " - " << current-
>data.nim << " - " << current->data.ipk << endl;
current = current->next;
}
}

main.cpp

// main.cpp
#include "mylist.h"

bool checkIsInputBreaked(int nim, const infoType& collegeStudent);


int mainMandiri();

int main() {
// Initialize Variable
List list;
address pointer, temporary;
infoType collegeStudent;

// Create New List


createList(list);

// Print The List


printList(list);

// Create New Colleage Student


collegeStudent = newCollegeStudent("Alice", "1301190202", 3.5);
// Create List Element
pointer = newElement(collegeStudent);
// Insert First To the list of the element
insertFirst(list, pointer);

// Create New Colleage Student


collegeStudent = newCollegeStudent("Bob", "1301190203", 4);
// Create List Element
pointer = newElement(collegeStudent);
// Insert First To the list of the element
insertFirst(list, pointer);

// Print The List


printList(list);

// Create New Colleage Student


collegeStudent = newCollegeStudent("Chihaya", "1301190204",
3.6);
// Create List Element
pointer = newElement(collegeStudent);
// Insert Last To the list of the element
insertLast(list, pointer);

// Create New Colleage Student


collegeStudent = newCollegeStudent("Delta", "1301190205", 2.7);
// Create List Element
pointer = newElement(collegeStudent);
// Insert Last To the list of the element
insertLast(list, pointer);

// Create New Colleage Student


collegeStudent = newCollegeStudent("Euniche", "1301190201",
3.9);
// Create List Element
pointer = newElement(collegeStudent);
// Insert Last To the list of the element
insertFirst(list, pointer);

// Print The List


printList(list);

// Delete First element in the list


deleteFirst(list, temporary);
// Delete Last element in the list
deleteLast(list, temporary);
// Print the List
printList(list);

// Execute Main Mandiri


mainMandiri();
return 0;
}

int mainMandiri() {
// Initialize Variable
List list;
address pointer, temporary;
infoType collegeStudent;
int numberOfData;
int myNim = 1301218680;
string name;
string nim;
double ipk;

// Create New List


createList(list);
printList(list);

cout << "Number of input data: ";


cin >> numberOfData;
cout << "\n";

int i = 1;
bool isInputBreaked = false;
while (i <= numberOfData && !isInputBreaked) {
cout << "Data " << i << "\n";
cout << "Name : ";
cin.ignore();
getline(cin, name, '\n');
cout << "NIM : ";
cin >> nim;
cout << "IPK : ";
cin >> ipk;

collegeStudent = newCollegeStudent(name, nim, ipk);


pointer = newElement(collegeStudent);
if (myNim % 2 == 0) {
insertFirst(list, pointer);
} else {
insertLast(list, pointer);
}
isInputBreaked = checkIsInputBreaked(myNim, collegeStudent);
i++;
}
printList(list);
deleteAllAndOutputElement(list, myNim % 2);
printList(list);
return 0;
}
bool checkIsInputBreaked(int nim, const infoType& collegeStudent) {
int modulo = nim % 3;
const char STRIP_SYMBOL = '-';
bool isInputBreaked = false;
switch (modulo) {
case 2: {
if (collegeStudent.nim.find(STRIP_SYMBOL) !=
string::npos &&
collegeStudent.name.find(STRIP_SYMBOL) !=
string::npos) {
isInputBreaked = true;
}
}break;
case 1: {
if (collegeStudent.nim.find(STRIP_SYMBOL) !=
string::npos) {
isInputBreaked = true;
}
}break;
case 0: {
if (collegeStudent.name.find(STRIP_SYMBOL) !=
string::npos) {
isInputBreaked = true;
}
}break;
default:
break;
}
return isInputBreaked;
}

KESIMPULAN
Dengan implementasi Modified Linked List (MLL), sistem pendataan mahasiswa dan dosen
wali dapat diorganisir dengan baik. MLL memungkinkan pengelolaan hubungan antar data, seperti
hubungan antara mahasiswa dan dosen wali dalam konteks tugas besar ini. Program ini memberikan
dasar untuk pengembangan sistem lebih lanjut yang dapat memenuhi kebutuhan pengguna dalam
pendataan mahasiswa dan dosen wali.

Anda mungkin juga menyukai