| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 809 人关注过本帖
标题:[求助](已解决)一个ATM小程序,问题很多,请大虾们帮帮忙
只看楼主 加入收藏
shengwumozhe
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-10-24
收藏
 问题点数:0 回复次数:5 
[求助](已解决)一个ATM小程序,问题很多,请大虾们帮帮忙

谢谢radcat和song4两位版主回答我的问题^_^
----------------------------------------------------------------------
这是个模拟银行提款机的简易程序,该一共包含三个文件.(*This is program is unfinished)
被注释掉的代码表示该代码还在测试和开发当中.
-----------------------------------------------------------------------------
//Cpp1.cpp
#include<iostream.h>
#include<string.h>
#include"Savings.h"
void main()
{
//loading.....
Savings save[30]={Savings("mashengbo","abc123"),Savings("maozhendong","abc456"),Savings("yangmaosheng","abc789"),Savings("zengfanpu","cba123"),Savings("baiweiwei","cba456"),Savings("hanyang","cba789")};

//menu.........
int chooseno_a;
cout<<"Welcome to Construction Bank.Connecting data......"<<endl;
cout<<"1-Login"<<" 2-Register"<<" 3-Help"<<" 4-Exit"<<endl;
cin>>chooseno_a;
/*if (chooseno_a==1) goto loop_b;
else if (chooseno_a==2) goto loop_regist;
else if (chooseno_a==3) cout<<"connecting help information..."<<endl;
else if (chooseno_a==4) {cout<<"quitting......\nPlease close the windows^_^"<<endl;goto loop_end;}
else cout<<"Error input"<<endl;*/

//input and checking operation....
loop_b:
char input_name[20],input_pass[20];
cout<<"please enter your name:"<<endl;
cin>>input_name;
cout<<"Please enter your password:"<<endl;
cin>>input_pass;
for (int i=0,int temp=0;i<30;i++)
{
if (save[i].Check(input_name,input_pass)==1)
temp=1;
if (temp==1)
{
cout<<"Login successfully...."<<endl;
goto loop_ok;
}
}
cout<<"The user is unfound,please enter again."<<endl;
goto loop_b;


//loop_ok,login successfully
loop_ok:
cout<<"Connecting the account......"<<endl;

//the following code is just for stoppting the program.
/*loop_end:
*/ cout<<"Program finsiehed...Please close the window..."<<endl;
for(;;)
{int wait;
cin>>wait;}
/*loop_regist:
cout<<"Connecting the regist system......"<<endl;*/

}
----------------------------------------------------------------
//Savings.cpp
#include<iostream.h>
#include<string.h>
#include"Savings.h"

Savings::Savings(char x[20],char y[20])
{
strcpy(IDname,x);
strcpy(password,y);
}

Savings::Savings()
{
strcpy(this->IDname,"noname");
strcpy(this->password,"void");

}

Savings::~Savings()
{
}

int Savings::Check(char x[20],char y[20])
{
if (strcmp(x,this->IDname)==0)
{
if (strcmp(y,this->password)==0)
return 1;
}

else return 0;
}

------------------------------------------------------------------------
//Savings.h
#include<iostream.h>
class Savings
{
public:
Savings();
Savings(char *,char *);
virtual ~Savings();
int Check(char *,char *); //check the password is it is correct.

protected:
char IDname[20];
char password[20];

};
-----------------------------------------------------------------------------
我是大一新生,自己看了看书,水平有限。希望各位高手能够详细的指点。十分感谢!
程序已经放出来了,我想制作一个模仿ATM的程序。

question one:查找问题(已解决)
考虑到实际,必须保护用户名和密码的安全。所以我选择用类来做。可是在检查密码是否正确遇到了问题。我想设一个成员函数CHECK收到用户名和密码后,可以调出正确密码和输入密码进行比较,通过返回0和1值判断是否可以继续程序。可是在调用户名时,发现,类只是个模子,不可以分配空间,怎样可以使类的内部函数具有查找数据的功能是我十分疑惑的地方。


question twe:隐身问题(已解决)
在输入密码时,怎样实现隐身功能?就是,怎样使输入时在屏幕显示“****”而不显示真实的密码?

question three:菜单引导问题(已解决)
教科书上说GOTO不要经常使用,不利于可读性。可是像在原程序中菜单部分的引导除了GOTO,还可以用什么方法可以实现呢?



[此贴子已经被作者于2006-11-7 15:41:00编辑过]

搜索更多相关主题的帖子: ATM 
2006-11-07 09:33
shengwumozhe
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-10-24
收藏
得分:0 

自信,微笑^_^
2006-11-07 11:23
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
收藏
得分:0 
下面这个是星号自已试一下吧
#include <iostream.h>
#include<conio.h>
void main()
{
char a[5];
cout<<"Please input password(5 bits):"<<endl;

for(int i=0;i<5;i++)
{
a[i]=getch();//无回显
cout<<"*";
};
cout<<a<<endl;
}
至于那个goto不是说不经常用就行吗该用还是用吧我也常用:-)

2006-11-07 12:01
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
question 3
MENU:显示菜单
do{
int choose;
do
{
cin>>choose;
if
1.2.3.4.fuction............
5.break;
}while((choose<=4)&&(choose>=1));

}while(choose!=5);
或者用switch做,代替里面的do while
不过建议用switch 简洁明了
goto不行用,坚决不行,你现在还不能为你的程序未来买单
我这个是我自己做的 ,跟老师讲的不一样。你们老师谁来着?
(这种帖别在这里面发,这里不探讨这个)

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-11-07 13:27
shengwumozhe
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2006-10-24
收藏
得分:0 
王晓强- -.
what's up?

问题帖发到教师版里么?

现在我们刚讲到C语言的for语句- -


谢谢radcat和song4 回答偶の问题^_^

[此贴子已经被作者于2006-11-7 15:35:07编辑过]


自信,微笑^_^
2006-11-07 15:29
df_hx
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-10-31
收藏
得分:0 
我感觉好像要用到数据库的一点儿知识吧?

2006-11-07 22:22
快速回复:[求助](已解决)一个ATM小程序,问题很多,请大虾们帮帮忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015351 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved