电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

java bank项目--精选文档

30页
  • 卖家[上传人]:夏**
  • 文档编号:471031522
  • 上传时间:2023-12-27
  • 文档格式:DOC
  • 文档大小:69KB
  • / 30 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、Java 基础实战Bank 项目实验题目 1:创建一个简单的银行程序包实验目的:Java 语言中面向对象的封装性及构造器的创建和使用。实验说明:在这个练习里,创建一个简单版本的 Account 类。将这个源文件放入 banking 程序包中。在创建单个帐户的默认程序包中,已编写了一个测试程序 TestBanking。这个测试程序初始化帐户余额,并可执行几种简单的事物处理。最后,该测试程 序显示该帐户的最终余额。提示:1创建 banking 包2 在 banking 包下创建 Account 类。该类必须实现上述 UML 框图中的模型。a. 声明一个私有对象属性:balance,这个属性保留了银行帐户的当前(或 即时)余额。b. 声明一个带有一个参数(init_balance)的公有构造器,这个参数为 balance 属性赋值。c. 声明一个公有方法 geBalance,该方法用于获取经常余额。d. 声明一个公有方法 deposit,该方法向当前余额增加金额。e. 声明一个公有方法 withdraw 从当前余额中减去金额。3打开TestBanking.java文件,按提示完成编写,并编译

      2、 TestBanking.java 文件。4 运行 TestBanking 类。可以看到下列输出结果:Creating an account with a 500.00 balanceWithdraw 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 (with an initial balance),* and performs a series of transactions with the Account object.*/package test;import banking.*;public class TestBanking public static void main(String args) Account account; / Cre

      3、ate an account that can has a 500.00 balance. System.out.println(Creating an account with a 500.00 balance.); /code System.out.println(Withdraw 150.00); /code System.out.println(Deposit 22.50); /code System.out.println(Withdraw 47.62); /code / Print out the final account balance System.out.println(The account has a balance of + account.getBalance(); Java 基础实战Bank 项目实验题目 2:扩展银行项目,添加一个 Customer 类。Customer 类将包含一个 Account对象。实验目的:使用引用类型的成员变量。提 示:1. 在banking包下的创建Customer类。该类必须实现上面的UML图表中的模型。a. 声明三个私有对

      4、象属性:firstName、lastName 和 account。b. 声明一个公有构造器,这个构造器带有两个代表对象属性的参数(f 和 l)c. 声明两个公有存取器来访问该对象属性,方法 getFirstName 和 getLastName 返回相应的属性。d. 声明 setAccount 方法来对 account 属性赋值。e. 声明 getAccount 方法以获取 account 属性。2. 在 exercise2 主目录里,编译运行这个 TestBanking 程序。应该看到如下输出结果:Creating the customer Jane Smith.Creating her account with a 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

      5、 creates a new Bank, sets the Customer (with an initial balance),* and performs a series of transactions with the Account object.*/import banking.*;public class TestBanking public static void main(String args) Customer customer; Account account; / Create an account that can has a 500.00 balance. System.out.println(Creating the customer Jane Smith.); /code System.out.println(Creating her account with a 500.00 balance.); /code System.out.println(Withdraw 150.00); /code System.out.println(Deposit 2

      6、2.50);/code System.out.println(Withdraw 47.62); /code / Print out the final account balance System.out.println(Customer + customer.getLastName() + , + customer.getFirstName() + has a balance of + account.getBalance(); Java 基础实战Bank 项目实验题目 3:修改 withdraw 方法以返回一个布尔值,指示交易是否成功。实验目的:使用有返回值的方法。提 示:1 修改 Account 类a. 修改 deposit 方法返回 true(意味所有存款是成功的)。b. 修改 withdraw 方法来检查提款数目是否大于余额。如果amt小于 balance, 则从余额中扣除提款数目并返回 true,否则余额不变返回 false。2 在 exercise3 主目录编译并运行 TestBanking 程序,将看到下列输出;Creating the customer Jane Sm

      7、ith.Creating her account with a 500.00 balance. Withdraw 150.00: trueDeposit 22.50: true Withdraw 47.62: true Withdraw 400.00: 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 (with an initial balance),* and performs a series of transactions with the Account object.*/import banking.*;public class TestBanking public static void main(String args) Customer customer; Account a

      8、ccount; / Create an account that can has a 500.00 balance. System.out.println(Creating the customer Jane Smith.);/code System.out.println(Creating her account with a 500.00 balance.); /code / Perform some account transactions System.out.println(Withdraw 150.00: + account.withdraw(150.00); System.out.println(Deposit 22.50: + account.deposit(22.50); System.out.println(Withdraw 47.62: + account.withdraw(47.62); System.out.println(Withdraw 400.00: + account.withdraw(400.00); / Print out the final account balance System.out.println(Customer + customer.getLastName() + , + customer.getFirstName() + has a balance of + account.getBalance(); Java 基础实战Bank 项目实验题目 4:将用数组实现银行与客户间的多重关系。

      《java bank项目--精选文档》由会员夏**分享,可在线阅读,更多相关《java bank项目--精选文档》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    监控施工 信息化课堂中的合作学习结业作业七年级语文 发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.