BAB II | Enkapsulasi interface
contoh program dengan C# :
/*
* Created by SharpDevelop.
* User: dino fajar rizkian
* Date: 12/05/2012
* Time: 8:35
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace iniface
{
interface sample
{
void face();
}
class faceinter:sample
{
public void face()
{
Console.WriteLine("http://adhidrawa.blogspot.com");
}
}
class Program
{
public static void Main(string[] args)
{
faceinter a= new faceinter ();
a.face();
Console.ReadKey(true);
}
}
}
gambarnya seperti ini :
dengan menggunakan java:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package interfacepkg;
interface contoh
{
public void face();
}
class inter implements contoh
{
public void face()
{
System.out.println("http://adhidrawa.blogspot.com");
}
}
public class Main {
public static void main(String[] args) {
inter a = new inter();
a.face();
}
}
gambarnya seperti ini:
dengan menggunakan C++ :
#include <iostream>
using namespace std;
class sample
{
public : void muka();
};
class faceinter :sample
{
public : void muka()
{
cout << "http://adhidrawa.blogspot.com";
}
};
int main()
{
faceinter a;
a.muka();
return 0;
}
gambarnya seperti ini:
0 komentar:
Posting Komentar