Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Class User +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- package pewarisan;
- import java.util.Scanner;
- public class user {
- public static void main(String[] args) {
- Televisi tv = new Televisi("TV Jaman Dulu,69 inc", 10);
- String[] allCenel = {"RCTI", "SCTV", "Indosiar", "TV one",
- "Metro TV", "Trans TV", "TPI", "TV 0",
- "TVRI", "TVG", "ANTV"};
- String[] cenelpaporit = {"RCTI", "SCTV", "Indosiar", "TV one"};
- //===================================================
- System.out.println("Kevin membeli Televisi : " + tv.getDiski());
- //===================================================
- //===================================================
- tv.getCN();
- tv.setCN(allCenel);
- tv.setCN(cenelpaporit);
- //===================================================
- //===================================================
- Scanner input = new Scanner(System.in);
- System.out.println("mau mengganti apa ?");
- System.out.println("1: voulume \n2: Channel");
- int stg = input.nextInt();
- switch (stg) {
- case 1:
- System.out.println("Silakan masukan volume yang ada inginkan 0~100");
- int NV = input.nextInt();
- tv.setVLM(NV);
- break;
- case 2:
- int c = cenelpaporit.length - 1;
- System.out.println("Silakan pilih channel dari 0 ~ " + c);
- int NC = input.nextInt();
- tv.setCNA(NC);
- break;
- default:
- System.out.println("eror");
- }
- //===================================================
- //tv.setCNA(3);
- //tv.setVLM(NV);
- //tv.setCNA(4);
- //tv.setCNA(5);
- //===================================================
- }
- }
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //++++++++++++++++++++++++++++++++++++++++++++++++ Class Televisi +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- package pewarisan;
- public class Televisi {
- private int JCN;
- public String[] CN = null;
- private int CNA;
- private int VLM;
- private String Diski;
- public Televisi(String Diski, int JCN) {
- this.Diski = Diski;
- this.JCN = JCN;
- }
- // ================================
- public int getJCN() {
- return JCN;
- }
- public void setJCN(int JCN) {
- this.JCN = JCN;
- }
- // ================================
- public String[] getCN() {
- if (CN == null) {
- System.out.println("Belum ada channel yang diset!");
- }
- return CN;
- }
- public void setCN(String[] CN) {
- this.CN = CN;
- if (CN.length > JCN) {
- System.out.println("maaf Televisi ini hanya dapat menyimpan : " + JCN + " Channel");
- } else {
- this.CN = CN;
- System.out.println("Channel Telah di Update!");
- }
- }
- // ================================
- public int getCNA() {
- return CNA;
- }
- public void setCNA(int CNA) {
- if (CNA > CN.length) {
- System.out.println("Channel yang Anda Pilih belum diset/Kosong!");
- return;
- }
- this.CNA = CNA;
- System.out.println("Pindah Ke Channel : " + CN[CNA]);
- }
- // ================================
- public int getVLM() {
- return VLM;
- }
- public void setVLM(int VLM) {
- this.VLM = VLM;
- if (VLM > 100) {
- System.out.println("Tolong kecilkan Volume Anda!\nVolume yang terlalu keras dapat merusak speaker dan telinga anda");
- }if (VLM<0){
- System.out.println("Anda taukan kalo volume "+VLM+" itu tidak nyata ??");
- }
- else {
- System.out.println("Volume diSet : " + VLM);
- }
- }
- // ================================
- public String getDiski() {
- return Diski;
- }
- public void setDiski(String Diski) {
- this.Diski = Diski;
- }
- // ================================
- }
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement