Skip to content

Instantly share code, notes, and snippets.

@galihlprakoso
Created January 13, 2019 03:09
Show Gist options
  • Save galihlprakoso/a67ef06e878a9e123151a821a43e4baa to your computer and use it in GitHub Desktop.
Save galihlprakoso/a67ef06e878a9e123151a821a43e4baa to your computer and use it in GitHub Desktop.
Solid Principle - GOD Class
package galihlprakoso.com.solidprinciple;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Locale;
/**
*
* @author galihlarasprakoso
*/
class GODClass {
private ArrayList<Integer> getListDataHarga(){
ArrayList<Integer> listDataHarga = new ArrayList<>();
listDataHarga.add(5000);
listDataHarga.add(6000);
listDataHarga.add(7000);
listDataHarga.add(8000);
listDataHarga.add(9000);
listDataHarga.add(10000);
return listDataHarga;
}
public ArrayList<String> ambilListHarga(){
ArrayList<Integer> listDataHarga = getListDataHarga();
ArrayList<String> listDataHargaFormatted = new ArrayList<>();
for (int i = 0; i < listDataHarga.size(); i++) {
String hargaFormatted = formatMataUang(listDataHarga.get(i));
listDataHargaFormatted.add(hargaFormatted);
}
return listDataHargaFormatted;
}
public String formatMataUang(Integer angka){
Locale localeID = new Locale("in", "ID");
NumberFormat format = NumberFormat.getCurrencyInstance(localeID);
return format.format(angka);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment