Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions assigntment-01/H071191026/Runer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import java.util.*;

public class Runer {

public static void main(String[] args) {
Map<String, String> facultyMap = new HashMap<>();
Map<String, String> majorMap = new HashMap<>();
facultyMap.put("Nama Fakultas Lain", "A");
facultyMap.put("Nama Fakultas Lain", "B");
facultyMap.put("Nama Fakultas Lain", "C");
facultyMap.put("Nama Fakultas Lain", "D");
facultyMap.put("Nama Fakultas Lain", "E");
facultyMap.put("Nama Fakultas Lain", "F");
facultyMap.put("Nama Fakultas Lain", "G");
facultyMap.put("MIPA", "H");
majorMap.put("Prodi Lain", "01");
majorMap.put("Prodi Lain", "02");
majorMap.put("Prodi Lain", "03");
majorMap.put("Prodi Lain", "04");
majorMap.put("Prodi Lain", "05");
majorMap.put("Prodi Lain", "06");
majorMap.put("Ilmu Komputer", "07");

Student student1 = new Student();
Student student2 = new Student();
Student student3 = new Student();

student1.setFirstname("mUHammAd");
student1.setLastname("fITRAH");
student1.setRegisterYear(2017);
student1.setFaculty("MIPA");
student1.setDepartemen("Matematika");
student1.setMajor("Ilmu Komputer");
student1.setId(facultyMap, majorMap);
student1.setEmail(facultyMap);

student2.setFirstname("KENNEDY");
student2.setLastname("");
student2.setRegisterYear(2017);
student2.setFaculty("MIPA");
student2.setDepartemen("Matematika");
student2.setMajor("Ilmu Komputer");
student2.setId(facultyMap, majorMap);
student2.setEmail(facultyMap);

student3.setFirstname("Khawaritzmi");
student3.setLastname("abdallah ahmad");
student3.setRegisterYear(2017);
student3.setFaculty("MIPA");
student3.setDepartemen("Matematika");
student3.setMajor("Ilmu Komputer");
student3.setId(facultyMap, majorMap);
student3.setEmail(facultyMap);

student1.desc();
;
student2.desc();
;
student3.desc();
;

}
}
99 changes: 99 additions & 0 deletions assigntment-01/H071191026/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import java.util.*;

public class Student {
private String id;
private String firstName;
private String lastName;
private String email;
private int registerYear;
private String faculty;
private String departemen;
private String major;

public void setId(Map<String, String> facultyMap, Map<String, String> majorMap) {
Random random = new Random();
id = facultyMap.get(faculty) + majorMap.get(major) + "1" + getRegisterYear() % 100 + "1"
+ (random.nextInt(60) + 1);
}

public void setFirstname(String firstName) {
this.firstName = firstName;
}

public void setLastname(String lastName) {
this.lastName = lastName;
}

public void setEmail(Map<String, String> facultyMap) {

String arr[] = getFullName().split(" ");
email = "";
email += arr[arr.length - 1].toLowerCase();
for (int i = 0; i < arr.length - 1; i++) {
email += (arr[i].substring(0, 1).toLowerCase());
}
email += getRegisterYear() % 100;
email += facultyMap.get(faculty).toLowerCase();
email += "@student.unhas.ac.id";
}

public void setRegisterYear(int registerYear) {
this.registerYear = registerYear;
}

public void setFaculty(String faculty) {
this.faculty = faculty;
}

public void setDepartemen(String departemen) {
this.departemen = departemen;
}

public void setMajor(String major) {
this.major = major;
}

public String getId() {
return id;
}

public String getEmail() {
return email;
}

public String getFaculty() {
return faculty;
}

public String getDepartemen() {
return departemen;
}

public String getMajor() {
return major;
}

public int getRegisterYear() {
return registerYear;
}

public String getFullName() {
String lowerString = (firstName + " " + lastName).toLowerCase();
String fullName = "";
String arr[] = lowerString.split(" ");
for (int i = 0; i < arr.length; i++) {
fullName += arr[i].charAt(0) + arr[i].substring(1, arr[i].length()) + " ";
}
return fullName;
}

public void desc() {
System.out.println("Nama : " + getFullName());
System.out.println("NIM : " + getId());
System.out.println("Email Mahasiswa : " + getEmail());
System.out.println("Fakultas : " + getFaculty());
System.out.println("Departemen : " + getDepartemen());
System.out.println("Program Studi : " + getMajor());
System.out.println();
}
}