编程教程
您现在的位置: 中国个人站长站 >> 网络编程 >> Javascript >> 教程正文 通过实例了解接口的含义
推荐位

通过实例了解接口的含义

中国个人站长站 Javascript 点击数: 更新时间:2007-7-27 8:49:45
今天试着写一个简单的银行存储小程序,只是一个内核思路而已,如果要完成所有功能,那还需要逐渐来完善的,代码如下:
public class test
{
 public static void main(String args[])
 {
  boolean blue=false;
  float money=0.00f;
  
  String xx;
  demo impl=new demo();
  blue=impl.regname("wenyu1314",12,8000.0f);
  if(blue)
  {
   System.out.println("Good luck! you have 8000$\n");
   System.out.println("UserName:  "+impl.username);
   System.out.println("UserID:    "+impl.userid);
   System.out.println("Money:     "+impl.money);
   System.out.println("-----------------------------------------------------------");
  }
  else
   System.out.println("Sorry!! this is system's worng");
   
  blue=impl.depost(500);
  if(blue)
   System.out.println("Good luck!");
  else
   System.out.println("Sorry!! this is system's worng1"); 
   
  money=impl.retive(12,20.0f); 
  if(money!=0.0f)
   {
    System.out.println("Good luck!");
    System.out.println("You have money is :  "+impl.money);
   } 
  else
   System.out.println("Sorry!! this is system's worng2");
   
   
  float money1=0.0f;
  blue=impl.getuserid(12); 
  if(blue)
   System.out.println("OK! you ID is money :   "+impl.money);
  else
   System.out.println("Sorry is not this userid");
 }
}
interface conner
{
 boolean regname(String username,int userid,float money);
 boolean depost(float money);
 float retive(int userid,float money);
 boolean getuserid(int userid);
}
class demo implements conner
{
 String username;
 int userid;
 float money;
 
 public demo(){};
 public demo(String username,int userid,float money)
 {
  this.username=username;
  this.userid=userid;
  this.money=money;
 }
 
 public boolean regname(String username,int userid,float money)
 {
  this.username=username;
  this.userid=userid;
  this.money=money;
  return true;
 }
 public float retive(int userid,float money)
 {
  if(userid==this.userid)
   return money;
  else
   return 0.00f;
 }
 public boolean depost(float money)
 {
  

[1] [2] 下一页

教程录入:swh    责任编辑:swh 
个人站长站与你风雨同舟!
本站所提供的资源均来源于互联网,如有侵权行为,请与本站管理员联系,我们会第一时间删除!
·如果您发现《通过实例了解接口的含义》文章有错误,也请通知我们修改!
联系邮箱chinageren#126.com,谢谢支持!
站内搜索:
广告服务 | 友情链接 | 联系我们 | 免责声明 | 用户留言 | 网站导航
版权所有:中国个人站长站 2007-2008 未经授权禁止复制或建立镜像 客服QQ号:112731235
copyright © 2007-2008 www.ChinaGeRen.com online services. all rights reserved. 苏ICP备05000059号