--%>

Programming with C#

QUESTION 1      

The following UML diagram describes an abstract class Customer. This class is to be used as part of a Company's inventory system. The inventory system will contain many different types of customers.  A separate subclass of Customer will be written for each type of customer. Once a customer is created, their identification will never change.

Using the given information and the UML diagram below you are to write the C# code for the Customer class only.

 

Customer {abstract}

 

 

-identification : string

-name : string

-address : string

 

 

+Customer(id : string, name : string, address : string)

+GetIdentification(): string

+GetName(): string

+SetName(name : string)

+GetBillingType():BillingType {abstract}

 

QUESTION 2                                                                                                

Write a method using the method header below.

   public void Reverse( double [] values, int start, int finish){ 

This method will reverse the elements in an array between a lower index position and an upper index position.

So given the following array declaration

                double [] data = {8.5, 12.0, 23.2, 18.0, 15.5, 5.0, 10.5};

following a call to the method Reverse(data, 2, 5); the contents of data would be

                {8.5, 12.0, 5.0, 15.5, 18.0, 23.2, 10.5}

Assume that you have already written a method called swap that swaps two elements in an array; the elements identified by the two index values passed as parameters:

Swap(array, oneIndex, otherIndex)

QUESTION 3                                                                                    

(a)          Write a method, IsVowel, which returns the value true if the supplied lowercase character is a vowel, otherwise return false. Use the following method heading.

                ///

      /// pre: ch is a lowercase alhpabethic character

                ///                           'a' <= ch <= 'z'

                ///

                /// post: returns true is ch is a vowel, otherwise false

      ///

      ///

      /// true if ch is in {'a', 'e', 'i', 'o', 'u'}

public bool IsVowel(char ch)

Note: only the lowercase letters, a, e, i, o, u are vowels. There is no need to include the XML comment in your answer.

(b)          In the formulation of a test plan for the method isVowel, what would be two (2) obvious test categories to include in the test plan?

QUESTION 4                                                                                                     

A common operation on a list is to find the "largest" value in a list.  Write an algorithm which will find the "second largest" value in a list. You can assume that the list will contain at least 2 values and that no value is duplicated.  Do not write C# code as your answer, but the algorithm should be at a level of detail that would lend itself to implementation in C# or any other programming language.

The algorithm should not make use of any supplied functionality, e.g. C# Array class methods such as Sort etc. It is also assumed that this algorithm would be implemented as a method which returns the location of the second largest value of the list and that the order of the values within the list is unchanged. This means that one cannot simply sort the array in ascending order and return (list.Length-2) as it is assume that the list will be passed by reference to this method.

 

 

 

 

 

   Related Questions in Programming Languages

  • Q : Explain Enumerated type Enumerated type

    Enumerated type: A data type-not directly accessible in Java - in which symbolic names are employed for a series of constant numeric values. They facilitate the evading of magic numbers. They can be simulated in the Java with fields i

  • Q : Define Identifiers Define Identifiers

    Define Identifiers and their naming convention in brief?

  • Q : Explain Untyped Allocations Untyped

    Untyped Allocations: In C/C++ untyped allocations such as malloc, calloc, and realloc can easily be used to create overlays, which again require translation overhead to keep the corresponding non-overlaid objects consistent.

    Q : Grep command Specify the usage of the

    Specify the usage of the “grep” command?

  • Q : Explain the relationship between XHTML

    Explain the relationship between XHTML and URL?

  • Q : Explain LURCH LURCH (Menzies et al.

    LURCH (Menzies et al. 2004) uses random search to explore a state machine’s state space. Because the search is random, it gives no guarantee that the state space has been exhaustively explored, so LURCH cannot be used for verification. However,

  • Q : Property Specifications of Java

    Property Specifications: The most straightforward way to specify and check simple safety properties in JPF is to use Java assertions inside the application under analysis. This allows the specification of properties that only depend on the application

  • Q : Define Aliases Aliases : It is a

    Aliases: It is a multiple references to a single object. Messages might be sent to the object through any of its aliases. The resultant state modifications will be detectable by all.

  • Q : Define Permission Normal 0 false false

    Normal 0 false false

  • Q : Define Class scope Class scope :

    Class scope: Private variables stated outside the methods in a class contain class scope. They are available from all methods within a class, in spite of the order in which they are stated. The private methods too contain class scope. Variables and me