From cd31164a405ed3878d38acb4fe43123e7cc48f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AE=88=E5=BA=B7?= <2994614654@qq.com> Date: Thu, 28 Apr 2022 12:03:52 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7\346\234\254\346\226\207\346\241\243.txt" | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 "\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" diff --git "a/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" new file mode 100644 index 0000000..45d36c1 --- /dev/null +++ "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" @@ -0,0 +1,93 @@ +using System; + +namespace ConsoleApp1 +{ + class Program + { + static void OutPut( Interface1 t,double n) + { + Console.WriteLine("存后为{0}", t.cun(n)); + } + static void OutPut(double n,Interface1 t) + { + Console.WriteLine("存后为{0}", t.qu(n)); + } + static void Main(string[] args) + { + Interface1 a = new Account(); + for (; ; ) + { + + Console.WriteLine("存钱 取钱 查余额"); + string n = Console.ReadLine(); + if (n == "存钱") + { + Console.WriteLine("输入数量"); + double w = Convert.ToInt32(Console.ReadLine()); + OutPut(a, w); + } + else if (n == "取钱") + { + Console.WriteLine("输入数量"); + double w = Convert.ToInt32(Console.ReadLine()); + + OutPut(w,a ); + } + else + { + Console.WriteLine("余额为{0}", a.ye); + } + } + + } + } +} + + + + + +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ +//// 创建一个银行接口,有存钱,取钱方法,还有账号余额属性, +////然后实现这个接口。 +//// 定义一个Account类,在里面实现具体的存钱,取钱方法。并且实现余额的读取 +////属性 + + interface Interface1 + { + double ye { get; set; } + double qu(double a); + double cun(double a); + + } + class Account : Interface1 + { + double _a { get; set; } + public double ye { get; set; } + + public Account() + { + ye = 0; + } + + public double qu(double _a) + { + Console.WriteLine("存钱前余额为{0}\n", ye); + ye = ye - _a; + return ye; + } + public double cun(double _a) + { + Console.WriteLine("存钱前余额为{0}\n", ye); + ye = ye + _a; + return ye; + } + } + +} + -- Gitee