Membuat Object dengan class Abstract, Minimal 3 Subclass dan 3 Method
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Abstract;
/**
*
* @author Toshiba
*/
public abstract class komputer {
public void keterangan () {
System.out.println("Macam - macam Alat Input, Storage, dan Output");
}
public abstract void nama();
public abstract void processor();
public abstract void memory();
public abstract void vga();
public static class komputer1 extends komputer {
@Override
public void nama() {
System.out.println("Laptop HP");
}
@Override
public void processor() {
System.out.println("intel® Pentium® Processor G870 (3M Cache, 3.10 GHz)");
}
@Override
public void memory() {
System.out.println("RAM 2 GB");
}
@Override
public void vga() {
System.out.println("VGA NVIDIA Geforce GTX 650 Ti");
}
}
public static class komputer2 extends komputer {
@Override
public void nama() {
System.out.println("Laptop Asus");
}
@Override
public void processor() {
System.out.println("Intel Core i3-3220 @ 3.30GHz");
}
@Override
public void memory() {
System.out.println("DDR3 1600 MHZ (6X4GB)");
}
@Override
public void vga() {
System.out.println("VGA ATI Radeon HD3200");
}
}
public static class komputer3 extends komputer {
@Override
public void nama() {
System.out.println("Laptop Toshiba");
}
@Override
public void processor() {
System.out.println("Intel Core i7 (3770) 3.4GHz");
}
@Override
public void memory() {
System.out.println("DDR3 1600 MHZ (2X2GB)");
}
@Override
public void vga() {
System.out.println("VGA Nvidia 8600GS ");
}
}
public static void main(String[] args) {
komputer1 x = new komputer1();
x.nama ();
x.processor( );
x.memory( );
x.vga( );
System.out.println("");
komputer2 y = new komputer2();
y.nama ();
y.processor( );
y.memory( );
y.vga( );
System.out.println("");
komputer3 z = new komputer3();
z.nama ();
z.processor( );
z.memory( );
z.vga( );
System.out.println("");
}
}
Posted by 08.17 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar