C#从零开始学习(封装(5)

本章所有的代码都放在
https://github.com/hikinazimi/head-first-Csharp

封装 被定义为"把一个或多个项目封闭在一个物理的或者逻辑的包中"。在面向对象程序设计方法论中,封装是为了防止对实现细节的访问。

抽象和封装是面向对象程序设计的相关特性。抽象允许相关信息可视化,封装则使开发者实现所需级别的抽象。

C# 封装根据具体的需要,设置使用者的访问权限,并通过 访问修饰符 来实现。

封装意味着对另一个类隐藏信息,但是封装中的信息可以使用反射拿出来

SwordDamage游戏

本项目是一个计算伤害的程序

第一版

<Window x:Class="SwordDamage_WPF_Part_1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SwordDamage_WPF_Part_1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <CheckBox x:Name="flaming" Content="Flaming"
            HorizontalAlignment="Center" VerticalAlignment="Center"
            Checked="Flaming_Checked" Unchecked="Flaming_Unchecked"/>

        <CheckBox x:Name="magic" Content="Magic" Grid.Column="1" 
            HorizontalAlignment="Center" VerticalAlignment="Center"
            Checked="Magic_Checked" Unchecked="Magic_Unchecked" />

        <Button Grid.Row="1" Grid.ColumnSpan="2" Margin="20,10" 
            Content="Roll for damage
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值