Angular Basics 3
Angular Basics 3
-------------------------------------------
Object oriented approach is a programming paradigm in which everything is modelled
as an object
-when we define a function inside a class,we dont use the keyword function
function globalfunc():void{....}
class MyClass{
localfunc():void{....}
}
___________________________________________________________
Lab1)Player.ts
write a class Player having data members
playerId,playerName,country,numMatches
Inheritance
-----------
is a property by the virtue of which an object is derived from other object
or an object acquires features of the other object
class A{....}
class B extends A{....}
eg:-
class Employee{empId,empName,jdate}
let earr:Employee[]=[];
earr.push(new Manager(....));
earr.push(new WageEmployee(....));
**super keyword is available to evry subclass to access any member of super class
Bowler.ts
------------
Write a class Bowler extends Player-->numWickets
ctor,DisplayInfo
caller.ts
---------
create an array of Player type---team holding 2 Batsman object & 2 Bowler objects
& display all players using for-of loop
eg:
let team:Player[]=[p1,p2];
here p1 is a Batsman object
& p2 is a Bowler object
_________________________________________________________
Polymorphism:
class A{...}
How to use this class A?
1)creating object
let ob:A=new A();
2)by extending it
class B extends A{....}
interface in Typescript
-----------------------
Interface is a pure abstract class
is a contract[set of specifications]
Lab1)
ITune.ts
---------
create an interface ITune having a method Play()
Instruments.ts
--------------
write 3 classes Guitar,Piano & Violin implementing the interface ITune
CallerInstrument.ts
-------------------
create an array instruments:ITune[] holding Guitar,Piano & Violin objects & invoke
Play method
____________________________________________________________
Lab2)
Performer.ts
-------------
interface Performer{void Perform();}
Participants.ts
---------------
write 3 classes which implements interface
Juggler[beanBags]
Singer[song]
Magician[magicWords]
SeedIdol.ts
------------
create an array of Performer & invoke Perform method onit
let parr:Performer[]=[];
parr.push(new Juggler(5));
parr.push(new Singer("some song"));
parr.push(new Magician("some magic words"));
________________________________________________________
callerStudent.ts
----------------
create an array of Students & invoke PrintMarkSheet method