From 19d7d2f0bc3363055a3d7923586b30eed958d013 Mon Sep 17 00:00:00 2001 From: Assassin-plus <56057686+Assassin-plus@users.noreply.github.com> Date: Mon, 11 Jul 2022 00:20:47 +0800 Subject: [PATCH] =?UTF-8?q?CSharp=5F=E5=8D=A2=E5=AD=90=E6=9C=9F=5F?= =?UTF-8?q?=E6=9C=AA=E5=A4=AE-=E6=B0=B4=E6=9C=A811?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw1/hw1/Counting.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hw1/hw1/Counting.cs b/hw1/hw1/Counting.cs index b8e76f4..312b2a3 100644 --- a/hw1/hw1/Counting.cs +++ b/hw1/hw1/Counting.cs @@ -52,5 +52,30 @@ public class Counting : ICountableVariable // // 注意:是Variable被修改!!! // 如果Variable要被赋予的值与当前的值相同,这并不是被修改! + public int variable=0; + public int readTimes = 0; + public int writeTimes = 0; + public int ReadTimes { get{ + return readTimes; + }set{ + readTimes=value; + } } + public int WriteTimes { get{ + return writeTimes; + }set{ + writeTimes=value; + } } + public int Variable { get{ + readTimes++; + return variable; + } set{ + int temp = variable; + variable=value>=0?value : 0; + if(temp!=variable){ + writeTimes++; + } + + } + } } }