zoukankan      html  css  js  c++  java
  • 活代码LINQ——05

    片段代码:

    ' Exercise 9.3  Solution: Invoice.vb
    ' Invoice class.
    Public Class invoide ' declare variables for Invoice object
        Private partNumberValue As Integer
        Private partDescriptionValue As String
        Private quantityValue As Integer
        Private priceValue As Decimal   ' four-argument constructor
    
        Public Sub New(ByVal part As Integer, ByVal description As String, ByVal count As Integer, ByVal pricePerItem As Decimal)
            PartNumber = part
            PartDescription = description
            Quantity = count
            Price = pricePerItem
        End Sub ' New
    
        ' property for partNumberValue; no validation necessary
        Public Property PartNumber() As Integer
            Get
                Return partNumberValue
            End Get
    
            Set(ByVal value As Integer)
                partNumberValue = value
            End Set
        End Property ' PartNumber
    
        ' property for partDescriptionValue; no validation necessary
        Public Property PartDescription() As String
            Get
                Return partDescriptionValue
            End Get
    
            Set(ByVal value As String)
                partDescriptionValue = value
            End Set
        End Property ' PartDescription
    
        ' property for quantityValue; ensures value is positive
        Public Property Quantity() As Integer
            Get
                Return quantityValue
            End Get
    
            Set(ByVal value As Integer)
                If value > 0 Then ' determine whether quantity is positive
                    quantityValue = value ' valid quantity assigned
                End If
            End Set
        End Property ' Quantity
    
    
        ' property for pricePerItemValue; ensures value is positive
        Public Property Price() As Decimal
            Get
                Return priceValue
            End Get
    
            Set(ByVal value As Decimal)
                If value > 0 Then ' determine whether price is positive
                    priceValue = value ' valid price assigned
                End If
            End Set
        End Property ' Price
    
        ' return String containing the fields in the Invoice in a nice format
        Public Overrides Function ToString() As String
            ' left justify each field, and give large enough spaces so  all the columns line up
            Return String.Format("{0,-5} {1,-20} {2,-5} {3,6:C}", PartNumber, PartDescription, Quantity, Price)
        End Function ' ToString
    End Class ' Invoice
    
    
    ' **************************************************************************
    ' * (C) Copyright 1992-2009 by Deitel & Associates, Inc. and               *
    ' * Pearson Education, Inc. All Rights Reserved.                           *
    ' *                                                                        *
    ' * DISCLAIMER: The authors and publisher of this book have used their     *
    ' * best efforts in preparing the book. These efforts include the          *
    ' * development, research, and testing of the theories and programs        *
    ' * to determine their effectiveness. The authors and publisher make       *
    ' * no warranty of any kind, expressed or implied, with regard to these    *
    ' * programs or to the documentation contained in these books. The authors *
    ' * and publisher shall not be liable in any event for incidental or       *
    ' * consequential damages in connection with, or arising out of, the       *
    ' * furnishing, performance, or use of these programs.                     *
    ' **************************************************************************
    

    源于:visual basic 2008 how to program 

  • 相关阅读:
    5 年,只为了一个更好的校验框架
    springboot 中 inputStream 神秘消失之谜
    没啥用的黑科技——自动生成测试对象信息框架
    投资中最简单的事
    一个提升英文单词拼写检测性能 1000 倍的算法?
    基于 junit5 实现 junitperf 源码分析
    关于 junit4 90% 的人都不知道的特性,详解 junitperf 的实现原理
    性能测试到底该怎么做?
    从代码生成说起,带你深入理解 mybatis generator 源码
    java 实现中英文拼写检查和错误纠正?可我只会写 CRUD 啊!
  • 原文地址:https://www.cnblogs.com/xiehaofeng/p/10060827.html
Copyright © 2011-2022 走看看