Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
通过实例了解接口的含义

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

今天试着写一个简单的银行存储小程序,只是一个内核思路而已,如果要完成所有功能,那还需要逐渐来完善的,代码如下:
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)
 {
  this.money+=money;
  return true;
 }
 public boolean getuserid(int userid)
 {
  if(userid==this.userid)
   return true;
  else
   return false;
 }
}

听一位高手说,接口用处很多,写程序离不开接口,所以记录下来以防日后忘了^_^
通过今天写的这个小程序还明白了数据库存储数据大部分是通过数组的
也不知道哪根筋想到的,嘿嘿...
有时间写一个小型的数据库


相关文章

相关软件