LAB 2-INTRODUCTION
                                 BS-III (ADVANCED S/W ENG.)

Object-Oriented Concepts

Attribute: the basic data of the class.

Method (operation): an executable procedure that is encapsulated in a class and is designed to
   operate on one or more data attributes that are defined as part of the class.

Object: when specific values are assigned to all the resources defined in a class, the result is an
   instance of that class. Any instance of any class is called an object.

Discovering Classes
Discovering and defining classes to describe the structure of a computerized system is not an
   easy task. When the problem domain is new or unfamiliar to the software developers it can
   be difficult to discover classes; a cookbook for finding classes does not exist.

Classes Categories
Classes are divided into three categories:

Entity: models information and associated behavior that is long-lived, independent of the
   surrounding, application independent, and accomplishes some responsibility
Boundary: handles the communication between the system surroundings and the inside of the
   system, provides interface, and facilitates communication with other systems
Control: model sequencing behavior specific to one or more use cases. Control classes
   coordinate the events needed to realize the behavior specified in the usecase, and they are
   responsible for the flow of events in the use case


Exercise 1(identification of classes)

   Consider the following requirements for the Video Store system. Identify the candidate
   classes: The video store keeps in stock an extensive library of current and popular movie
   titles. A particular movie may be held on video tape or disk. Video tapes are in either "Beta"
   or "VHS" format. Video disks are in DVD format. Each movie has a particular rental period
   (expressed in days), with a rental charge to that period. The video store must be able to
   immediately answer any inquiries about a movie's stock availability and how many tapes
   and/or disks are available for rental. The current condition of each tape and disk must be
   known and recorded. The rental charge differs depending on video medium: tape or disk (but
   it is the same for the two categories of tapes: Beta and VHS).The system should accommodate
   future video storage formats in addition to VHStapes, Beta tapes and DVD disks. The
   employees frequently use a movie code, instead of movie title, to identify the movie. The
   same movie title may have more than one release by different directors. You may use any (or
   mix) of the class elicitation methods to find the candidate classes.
Following two exercises are the programming assignments to assess the student’s ability:

Programming assignment 1

   Create an inheritance hierarchy of Vehicle: Car, Bus and Truck, with the School Bus further
   extending the hierarchy through the Bus. Each of the derived class objects should be
   packaging information about category and passenger carrying capacity of that vehicle.
   Provide a method that is common to all derived classes, such as getPassengerCapacity (),
   with class Truck having an additional method called getLoadingCapacity () that should be
   returning that truck's loading capacity in tons. Create objects of all the derived classes in a
   test class and store the references in an array (4 Elements) of type Vehicle, the top-level class
   of this hierarchy. Provide logic so that at every run of the program any one of the four
   references stored in the array is randomly selected and the methods of that object are called
   polymorphically. Every random access must result in display of category and passenger
   carrying capacity of that particular vehicle, except in the case of a Truck object, where the
   call must result in the display of category, passenger carrying capacity and the cargo loading
   capacity.

Programming assignment 2

    In this assignment you are required to do some string processing. Consider the English word
   "CONTAMINATION". This word consists of 13 letters. However, some of the letters occur
   more than once. There are ONLY 7 DISTINCT letters occurring in the string which are {A,
   C, I, M, N, O, T}. So, although, the total number of letters in the word is 13, there are ONLY
   7 DISTINCT letters of the English alphabet in the string. Similarly, consider the word
   "RETREAT". It consists of 7 letters. However, there are only 4 DISTINCT letters in it which
   are {A, E, R, T}. Similarly the word "NEEDLE" consists of 6 letters but it contains ONLY 4
   DISTINCT letters which are {D, E, L, E}. Now consider the word "FLASHING". It consists
   of 8 letters. But since no letter is repeated, the number of DISTINCT letters occurring in it is
   ALSO 8. Similarly the number of DISTINCT letters occurring in the word "PROMISE" is
   the SAME (7) as the TOTAL number of letters occurring in it.

   Write program which inputs a word (having not more than 15 letters) from the
   keyboard and displays the number of DISTINCT letters occurring in it.

Advanced software engineering lab 2

  • 1.
    LAB 2-INTRODUCTION BS-III (ADVANCED S/W ENG.) Object-Oriented Concepts Attribute: the basic data of the class. Method (operation): an executable procedure that is encapsulated in a class and is designed to operate on one or more data attributes that are defined as part of the class. Object: when specific values are assigned to all the resources defined in a class, the result is an instance of that class. Any instance of any class is called an object. Discovering Classes Discovering and defining classes to describe the structure of a computerized system is not an easy task. When the problem domain is new or unfamiliar to the software developers it can be difficult to discover classes; a cookbook for finding classes does not exist. Classes Categories Classes are divided into three categories: Entity: models information and associated behavior that is long-lived, independent of the surrounding, application independent, and accomplishes some responsibility Boundary: handles the communication between the system surroundings and the inside of the system, provides interface, and facilitates communication with other systems Control: model sequencing behavior specific to one or more use cases. Control classes coordinate the events needed to realize the behavior specified in the usecase, and they are responsible for the flow of events in the use case Exercise 1(identification of classes) Consider the following requirements for the Video Store system. Identify the candidate classes: The video store keeps in stock an extensive library of current and popular movie titles. A particular movie may be held on video tape or disk. Video tapes are in either "Beta" or "VHS" format. Video disks are in DVD format. Each movie has a particular rental period (expressed in days), with a rental charge to that period. The video store must be able to immediately answer any inquiries about a movie's stock availability and how many tapes and/or disks are available for rental. The current condition of each tape and disk must be known and recorded. The rental charge differs depending on video medium: tape or disk (but it is the same for the two categories of tapes: Beta and VHS).The system should accommodate future video storage formats in addition to VHStapes, Beta tapes and DVD disks. The employees frequently use a movie code, instead of movie title, to identify the movie. The same movie title may have more than one release by different directors. You may use any (or mix) of the class elicitation methods to find the candidate classes.
  • 2.
    Following two exercisesare the programming assignments to assess the student’s ability: Programming assignment 1 Create an inheritance hierarchy of Vehicle: Car, Bus and Truck, with the School Bus further extending the hierarchy through the Bus. Each of the derived class objects should be packaging information about category and passenger carrying capacity of that vehicle. Provide a method that is common to all derived classes, such as getPassengerCapacity (), with class Truck having an additional method called getLoadingCapacity () that should be returning that truck's loading capacity in tons. Create objects of all the derived classes in a test class and store the references in an array (4 Elements) of type Vehicle, the top-level class of this hierarchy. Provide logic so that at every run of the program any one of the four references stored in the array is randomly selected and the methods of that object are called polymorphically. Every random access must result in display of category and passenger carrying capacity of that particular vehicle, except in the case of a Truck object, where the call must result in the display of category, passenger carrying capacity and the cargo loading capacity. Programming assignment 2 In this assignment you are required to do some string processing. Consider the English word "CONTAMINATION". This word consists of 13 letters. However, some of the letters occur more than once. There are ONLY 7 DISTINCT letters occurring in the string which are {A, C, I, M, N, O, T}. So, although, the total number of letters in the word is 13, there are ONLY 7 DISTINCT letters of the English alphabet in the string. Similarly, consider the word "RETREAT". It consists of 7 letters. However, there are only 4 DISTINCT letters in it which are {A, E, R, T}. Similarly the word "NEEDLE" consists of 6 letters but it contains ONLY 4 DISTINCT letters which are {D, E, L, E}. Now consider the word "FLASHING". It consists of 8 letters. But since no letter is repeated, the number of DISTINCT letters occurring in it is ALSO 8. Similarly the number of DISTINCT letters occurring in the word "PROMISE" is the SAME (7) as the TOTAL number of letters occurring in it. Write program which inputs a word (having not more than 15 letters) from the keyboard and displays the number of DISTINCT letters occurring in it.