C++课程设计报告 下载本文

内容发布更新时间 : 2024/5/19 13:39:28星期一 下面是文章的全部内容请认真阅读。

另外用户可以管理自己的信息,点击管理我的信息按钮便可以进入如下页面

在这个页面中用户可以修改自己的密码以及各种信息。

五、设计总结(可谈一谈本次课程设计的经验和体会)

通过本次课程设计,我掌握了如何给自己的程序设计上漂亮的界面,以及如何把不同的界面通过按钮连接起来,在这个界面中点击按钮,另一个界面会弹出来,并且实现相应的功能。实验过程中碰到许多问题,有个问题卡住了整整一下午,通过不断在网上查资料、问同学、查书籍,把所有的问题都解决了,走了不少弯路。但这些都成为了我的经验,因为走弯路会给人更多思考的机会,使我更加周全的考虑事情。把课程设计做完之后感觉自己又进步了许多,许多以前学不到的东西以及不熟悉的东西,甚至是一些以为自己明白了但实际上确实错误的东西都重新学习了一遍,加深了一遍。

至今我感慨颇多的应当是一些难以查出的错误,编译时查不出的错误,其被发现时很可能只是位置的错误,仅隔数行,这些微小的信息却极大地影响了整体的效果。这不仅存在于一个程序之中,因而我对于生活中的细节也有了改观,对于整体和局部的观念也有了更多的见解.

六、参考文献

[1] 李兰, 任凤华. C++面向对象程序设计. 西安: 西安电子科技大学出版社, 2010

[2] 李兰, 任凤华. 《C++面向对象程序设计》实验指导及习题解析. 西安: 西安电子科技大学出版社, 2010

[3] 郑莉, 董渊. C++程序设计基础教程. 北京: 清华大学出版社, 2010 [4] 郑莉. C++程序设计基础教程学生用书. 北京: 清华大学出版社, 2010

七、附录(要加上注释。)

以下是非系统生成的、自己写的代码,系统自动生成的代码比较多,没有附上。

15

private: System::Void button_login_Click(System::Object^ sender, System::EventArgs^ e) { String^ userName; String^ password; userName=textBox_userName->Text; password=textBox_password->Text; string s_use ,s_pass; MarshalString(userName,s_use); //System::String^ -> std::string MarshalString(password,s_pass); if(!judge(s_use,s_pass)) { label2->Text = \用??户?ì名?或¨°密¨1码?错?¨a误¨?!ê?\ return; } string name = \ name += s_use; name += \ ofstream output(\ output<Hide(); 功|能¨1 p; p.ShowDialog(); this->Close(); } private: System::Void button_register_Click(System::Object^ sender, System::EventArgs^ e) { this->Hide(); userRegister p1 ; p1.ShowDialog(); this->Close(); } private: bool judge(string s_use,string s_pass){ string acount; string password; ifstream input;

16

}

input.open(\ if(!input){ ofstream output(\ output<<\ output.close(); } int cnt = 1; while(input>>acount) { if(cnt%2==1) { if(acount == s_use) { input>>password; if(password != s_pass) { input.close(); return 0; } else { input.close(); return 1; } } } cnt++; } input.close(); return 0; //not found user }

void MarshalString ( String ^ s, string& os ) { using namespace Runtime::InteropServices; const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer(); os = chars; Marshal::FreeHGlobal(IntPtr((void*)chars));

17

private: System::Void button_registerOk_Click(System::Object^ sender, System::EventArgs^ e) { String^ acount = textBox1->Text; string s_user; MarshalString(acount,s_user); if(s_user==\ if(!judge(s_user)) //判D断?用??户?ì名?是o?不?是o?已°?经-存??在¨2 { label1->Text=\用??户?ì名?已°?经-存??在¨2!ê?\ return; } String^ p1 = textBox_password->Text; String^ p2 = textBox_surePassword->Text; if(p1==\ if(p1!=p2) //判D断?两¢?次??输o?入¨?的ì?密¨1码?一°?致?性? { label2->Text = \两¢?次??输o?入¨?的ì?密¨1码?不?一°?致?!ê?\ return; } //能¨1注á?é册¨¢&&密¨1码?合?适o¨o string s_pass; MarshalString(p1,s_pass); ofstream output(\ output<Hide(); 功|能¨1 p; p.ShowDialog(); } void MarshalString ( String ^ s, string& os ) { using namespace Runtime::InteropServices; const char* chars =

18

(const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer(); os = chars; Marshal::FreeHGlobal(IntPtr((void*)chars)); } bool judge(string input_name) { string cur_name; ifstream input(\ int cnt = 1; while(!input.eof()) //读¨¢到ì?文?件t尾2 { input>>cur_name; if(cnt%2==1) { if(cur_name == input_name){ input.close(); return 0; } } cnt++; } input.close(); return 1; }

private: System::Void button_eat_Click(System::Object^ sender, System::EventArgs^ e) { 点ì?菜? p1; p1.ShowDialog(); }

private: System::Void button_pay_Click(System::Object^ sender, System::EventArgs^ e) { pay p ; p.ShowDialog(); }

private: System::Void button_consumes_Click(System::Object^ sender, System::EventArgs^ e) { consume_record consume; consume.ShowDialog(); }

private: System::Void button_judge_Click(System::Object^ sender, System::EventArgs^ e) {

19