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 

  • 相关阅读:
    [转] EJB 3和Spring技术体系比较
    JBOSS只能本机localhost和127.0.0.1能访问的解决
    JBOSS EAP 6.0+ Standalone模式安装成Windows服务
    IBM WebSphere MQ 7.5基本用法
    maven学习(上)- 基本入门用法
    mac下环境变量、maven3.1.1 及 jdk1.7.0.45配置
    java:读/写配置文件
    java:使用匿名类直接new接口
    java与c#的反射性能比较
    XmlSpy / XSD 以及 验证
  • 原文地址:https://www.cnblogs.com/xiehaofeng/p/10060827.html
Copyright © 2011-2022 走看看