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 the COM components Explain the

    Explain the COM components?

  • Q : Difference between the choice and list

    Illustrate the difference between the choice and list?

  • Q : Define Hardware Hardware : It is the

    Hardware: It is the physical devices of a computer system, like its micro-chips, keyboard, disk drives, printer, sound card, and so forth. It is termed `hardware' in contrary to programs, which are termed `software'.

  • Q : Data types of LONG To define the data

    To define the data types such as LONG, INT, SHORT, CHAR write a program?

  • Q : Search and Coverage of SPIN Search and

    Search and Coverage of SPIN: SPIN has a highly optimized state exploration algorithm. It supports random, interactive and guided simulation, and both exhaustive and partial coverage, based on either depth-first or breadth-first search.

    Q : Define Short-circuit operator

    Short-circuit operator: It is an operator in which only as a lot of operands are computed as are required to determine the final outcome of the operation. The logical-and (&&) and logical-or (||) operators are most general illustration, though

  • Q : Define the term Key value Define the

    Define the term Key value: The object employed to produce an associated hash code for look-up in an associative data structure.

  • Q : Explain the important thing to HTML

    Explain the important thing to HTML document authors.

  • Q : Write a program and estimate pi using

    Consider a dartboard of radius 1. Since the area of the board will be  π r2 = π * 1 *1, it's clear the area of the dartboard is exactly π. The area of a square surrounding the board (circumscribing it) would be 2*2 = 4, sin

  • Q : Define the term Local inner class and

    Define the term Local inner class and Local variable: Local inner class: It is an inner class stated in a method. Local variable: It is a variable defined within

©TutorsGlobe All rights reserved 2022-2023.