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 : CORBA In what respects did CORBA seek

    In what respects did CORBA seek to improve on technologies such as SunRPC?

  • Q : State the term GPC and GPT State the

    State the term GPC and GPT.

  • Q : What is an Immutable object Immutable

    Immutable object: It is an object whose state might not be modified. The objects of String class are immutable, for example - their length and contents are fixed once formed.

  • Q : Explain Do loop Do loop : This is one

    Do loop: This is one of Java's three control structures employed for looping. The other two are the for loop and while loop. A do loop comprises of a loop body and a Boolean expression. The condition is tested subsequent to the loop body has been fini

  • Q : UK assignment & homework help Need UK

    Need UK Assignment Help, UK Homework Help. Get it now! HwA provides email based and live UK assignment help and UK homework help in a variety of subjects to the students based out

  • Q : What is Bounded repetition Bounded

    Bounded repetition: The Repetition where statements within a loop's body are executed a fixed number of times and the number of times is established whenever the loop began. There is no control structure in Java which guarantees the bounded repetition

  • Q : What is the use of compatibility testing

    What is the use of compatibility testing?

  • Q : Explain Two dimensional array Two

    Two dimensional array: A two dimensional array is a continuous memory location having similar kind of data arranged in row and column format (such as a matrix structure). D

  • Q : Define BOOP Toolkit BOOP Toolkit : The

    BOOP Toolkit: The BOOP Toolkit has been developed at the Institute for Software Technology at Graz University of Technology. It is based on the SLAM project and uses the same main concept of verification by abstraction and refinement to determin

  • Q : Double clock signal in synchronous

    Describes the cases where you need to double clock a signal before presenting this to a synchronous state machine?

©TutorsGlobe All rights reserved 2022-2023.