




免费预览已结束,剩余21页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
精选的文库基于Java的实战-bank项目实验标题1:建立简易银行套件实验目的:Java语言中面向对象的封装和构造函数的创建和使用。实验说明:在本练习中,您将创建帐户类的简单版本。将此源文件放入banking包中。在创建单个帐户的基本软件包中,创建了测试程序TestBanking。此测试程序初始化帐户馀额,并执行一些简单的处理。最后,测试过程显示了帐户的最终馀额。提示:1.创建banking软件包2.在banking包下创建Account类。此类必须实现上述UML方框图的模型。A.声明维护银行帐户当前(或立即)馀额的个人对象属性balance。B.声明具有一个参数(init_balance)的公共构造函数,该参数为balance属性赋值。C.声明geBalance,这是用于获取常规馀额的公共方法。D.声明deposit,这是增加当前馀额金额的公用方法。E.声明公共方法withdraw,以从当前馀额中减去金额。3.打开TestBanking.java文件,按照提示完成合成,然后编译TestBanking.java文件。4.运行TestBanking类。可以查看以下输出结果:使用500.00 balance创建帐户Withdraw 150.00Deposit 22.50Withdraw 47.62The account has a balance of 324.88/TestBanking.java文件/* this class creates the program to test the banking classes。* it creates a new bank,sets the customer,* and performs a series of transactions with the account object。*/打包测试;Import banking。*;Public class test bankingpublic static void main(stringargs)帐户帐户/create an account that can has a 500.00 balance。system . out . print ln( creating an account with a 500.00 balance . );/代码system . out . print ln( with draw 150.00 );/代码system . out . print ln( deposit 22.50 );/代码system . out . print ln( with draw 47.62 );/代码/print out the final account balancesystem . out . print ln( the account has a balance of account . get balance();基于Java的实战-bank项目实验标题2:扩展银行项目并添加客户类。Customer类包含一个Account对象。实验目的:使用引用类型的成员变量。杰西:1.在banking包下创建Customer类。此类必须实现上述UML图的模型。A.声明三个专用对象属性:firstName、lastName和account。B.声明具有两个参数(f和l)的公共构造函数以表示对象的属性C.声明两个公共存取器以访问对象属性时,将返回getFirstName和getLastName方法返回到属性。D.声明setAccount方法以向Account属性赋值。E.声明getAccount方法以获取Account属性。2.在exercise2主目录中编译并运行此TestBanking程序。应显示以下输出:Creating the customer Jane Smith。使用500.00 balance创建帐户。Withdraw 150.00Deposit 22.50Withdraw 47.62Customer Smith,Jane has a balance of 324.88/TestBanking.java文件/* this class creates the program to test the banking classes。* it creates a new bank,sets the customer,* and performs a series of transactions with the account object。*/Import banking。*;Public class test bankingpublic static void main(stringargs)客户客户帐户帐户/create an account that can has a 500.00 balance。system . out . print ln( creating the customer Jane Smith . );/代码system . out . print ln( creating her account with a 500.00 balance . );/代码system . out . print ln( with draw 150.00 );/代码system . out . print ln( deposit 22.50 );/代码system . out . print ln( with draw 47.62 );/代码/print out the final account balancesystem . out . print ln( customer customer . get last name(), customer.getFirstName()has a balance of account . get balance();基于Java的实战-bank项目实验标题3:修改Withdraw方法以返回一个布尔值,指示事务是否成功。实验目的:使用具有返回值的方法。杰西:1.修改Account类A.修改deposit方法,返回true(表示所有存款都成功)。B.修改withdraw方法以查看提取数是否大于馀额。如果Amt小于balance,则从馀额中减去提取数,并返回true。否则,馀额不会返回false。2.在exercise3主目录中编译并运行TestBanking程序时,将显示以下输出:Creating the customer Jane Smith。creating her account with a 500.00 balance . with draw 150.003360 truedeposit 22.503360 true with draw 47.62: true with draw 400.003360 falseCustomer Smith,Jane has a balance of 324.88/TestBanking.java文件/* this class creates the program to test the banking classes。* it creates a new bank,sets the customer,* and performs a series of transactions with the account object。*/Import banking。*;Public class test bankingpublic static void main(stringargs)客户客户帐户帐户/create an account that can has a 500.00 balance。system . out . print ln( creating the customer Jane Smith . );/代码system . out . print ln( creating her account with a 500.00 balance . );/代码/perform some account transactionssystem . out . print ln( with draw 150.003360 account . withdraw(150.00)system . out . print ln( deposit 22.503360 account . deposit(22.50);system . out . print ln( with draw 47.62: account . withdraw(47.62)system . out . print ln( with draw 400.003360 account . withdraw(400.00)/print out the final account balancesystem . out . print ln( customer customer . get last name(), customer.getFirstName()has a balance of account . get balance();基于Java的实战-bank项目实验标题4:阵列体现了银行和客户之间的多种关系。实验目的:类使用数组作为模拟集合操作。提示:对于银行,可以添加银行类。银行对象跟踪自身和客户之间的关系。此集合关系是使用Customer对象的数组实现的。还必须保留整数属性,以跟踪当前有多少客户在银线上。创建银行组类B.向Bank类添加两个属性:customers(Customer对象的数组)和numberOfCustomers(跟踪以下customers数组索引的整数)C.添加公用构造函数,以使用适当的最大大小(至少5个)初始化customers数组。D.添加addCustomer方法。此方法需要根据参数(姓,名)配置新客户然后,将对象放入customer数组中。此外,numberofCustomers属性值应加上1。E.添加返回numberofCustomers属性值的getNumOfCustomers访问方法。F.添加getCustomer方法。返回与给定index参数相关联的客户。G.编译并运行TestBanking程序。可以查看以下输出结果:Customer 1 is Simms,JaneCustomer 2 is Bryant,OwenCustomer 3 is Soley,TimCustomer 4 is Soley,Maria/TestBanking.java文件/* this class creates the program to test the banking classes。* it creates a new bank,sets the customer,* and performs a se
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年赛隆(SIALON)高温工程陶瓷项目合作计划书
- 2025防水材料行业产品性能提升技术服务合同
- 二零二五年供用电合同担保与电网调度服务协议
- 二零二五年度影视制作合伙人版权合同
- 2025房地产项目工程监理委托协议
- 二零二五年度物流仓储服务外包合同
- 二零二五年度大数据平台采购及数据分析服务合同
- 二零二五年度主题餐厅租赁经营合同
- 心理健康课件-认识自己
- 2025版离婚协议书存款分割与婚姻终止后子女监护权协议
- 大一计算机考试真题单选题100道及答案
- 信用卡消费者保护培训
- 青蓝工程工作总结师傅
- 石油化工生产与操作作业指导书
- 广场项目基坑监测工程技术投标书
- 卫生间卫浴知识培训课件
- 面部损伤护理查房
- 【初中数学】第六章 变量之间的关系同步练习 2024-2025学年北师大版七年级数学下册
- 电子废弃物回收利用-深度研究
- 2025版小细胞肺癌免疫治疗专家共识解读
- 水吸收丙酮填料塔的设计
评论
0/150
提交评论