Skip to content

Feature/angular training #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Day-2/Emp.js
Empty file.
44 changes: 24 additions & 20 deletions Day-2/Employee.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
"use strict";
exports.__esModule = true;
var Employee = (function () {
function Employee(id, name, salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
Employee.prototype.printInfo = function () {
console.log(this.name + " gets " + this.salary);
};
Employee.prototype.updateSalary = function (newSalary) {
this.salary = newSalary;
};
Employee.prototype.getSalary = function () {
return this.salary;
};
return Employee;
}());
exports.Employee = Employee;
"use strict";
exports.__esModule = true;
var Employee = (function () {
function Employee(id, name, salary, rating) {
this.id = id;
this.name = name;
this.salary = salary;
this.rating = rating;
}
Employee.prototype.printInfo = function () {
console.log(this.name + " gets " + this.salary);
};
Employee.prototype.updateSalary = function (newSalary) {
this.salary = newSalary;
};
Employee.prototype.getSalary = function () {
return this.salary;
};
Employee.prototype.getRating = function () {
return this.rating;
};
return Employee;
}());
exports.Employee = Employee;
9 changes: 8 additions & 1 deletion Day-2/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ export class Employee {
id: number;
name: string;
salary: number;
constructor(id: number, name: string, salary: number) {
rating:number;
constructor(id: number, name: string, salary: number, rating:number) {
this.id = id;
this.name = name;
this.salary = salary;
this.rating = rating;
}
printInfo() {

console.log(`${this.name} gets ${this.salary}`);
}
updateSalary(newSalary: number) {
Expand All @@ -16,5 +19,9 @@ export class Employee {
getSalary() {
return this.salary;
}

getRating(){
return this.rating;
}
}

53 changes: 27 additions & 26 deletions Day-2/Organization.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
"use strict";
exports.__esModule = true;
var Employee_1 = require("./Employee");
var Organization = (function () {
function Organization(name) {
this.name = name;
this.listOfEmployees = [];
}
Organization.prototype.createEmployees = function () {
for (var i = 1; i <= 10; i++) {
var emp = new Employee_1.Employee(i, 'A' + i, i * 1000);
this.listOfEmployees.push(emp);
}
};
Organization.prototype.printEmployeesInfo = function () {
this.listOfEmployees.map(function (emp) { return emp.printInfo(); });
// this.listOfEmployees.map(function(emp) {
// return emp.printInfo();
// })
};
Organization.prototype.getEmployeeList = function () {
return this.listOfEmployees;
};
return Organization;
}());
exports.Organization = Organization;
"use strict";
exports.__esModule = true;
var Employee_1 = require("./Employee");
var Organization = (function () {
function Organization(name) {
this.name = name;
this.listOfEmployees = [];
}
Organization.prototype.createEmployees = function () {
for (var i = 1; i <= 10; i++) {
var rating = Math.floor(Math.random() * (5 - 1 + 1) + 1);
var emp = new Employee_1.Employee(i, 'A' + i, i * 1000, rating);
this.listOfEmployees.push(emp);
}
};
Organization.prototype.printEmployeesInfo = function () {
this.listOfEmployees.map(function (emp) { return emp.printInfo(); });
// this.listOfEmployees.map(function(emp) {
// return emp.printInfo();
// })
};
Organization.prototype.getEmployeeList = function () {
return this.listOfEmployees;
};
return Organization;
}());
exports.Organization = Organization;
3 changes: 2 additions & 1 deletion Day-2/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class Organization {
}
createEmployees() {
for (let i = 1; i <= 10; i++) {
let emp: Employee = new Employee(i, 'A' + i, i * 1000);
let rating = Math.floor(Math.random()*(5-1+1)+1);
let emp: Employee = new Employee(i, 'A' + i, i * 1000,rating);
this.listOfEmployees.push(emp);
}
}
Expand Down
6 changes: 6 additions & 0 deletions Day-2/cricket-match/ExecuteMatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use strict";
exports.__esModule = true;
var Match_1 = require("./Match");
var match = new Match_1.Match();
match.createMatch("IND-NZ-ODI", "ODI", 50);
match.printPlayerInfo("Player 5");
6 changes: 6 additions & 0 deletions Day-2/cricket-match/ExecuteMatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Match } from './Match';
import { Player } from './Player';

var match: Match = new Match();
match.createMatch("IND-NZ-ODI","ODI",50);
match.printPlayerInfo("Player 5");
19 changes: 19 additions & 0 deletions Day-2/cricket-match/Player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
exports.__esModule = true;
var Player = (function () {
function Player(id, name, score, balls, wickets) {
this.id = id;
this.name = name;
this.score = score;
this.balls = balls;
this.wickets = wickets;
}
Player.prototype.printInfo = function () {
console.log(this.name + " scored " + this.score + " in " + this.balls + " balls");
};
Player.prototype.updateScore = function (score) {
this.score = score;
};
return Player;
}());
exports.Player = Player;
20 changes: 20 additions & 0 deletions Day-2/cricket-match/Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export class Player {
id: number;
name: string;
score: number;
balls:number;
wickets:number;
constructor(id: number, name: string, score: number, balls:number,wickets:number) {
this.id = id;
this.name = name;
this.score = score;
this.balls = balls;
this.wickets = wickets
}
printInfo() {
console.log(`${this.name} scored ${this.score} in ${this.balls} balls`);
}
updateScore(score:number){
this.score = score
}
}
30 changes: 30 additions & 0 deletions Day-2/cricket-match/match.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
exports.__esModule = true;
var Player_1 = require("./Player");
var Match = (function () {
function Match() {
}
Match.prototype.createPlayers = function () {
this.listOfPlayers = [];
for (var i = 1; i <= 11; i++) {
//let Score = Math.floor(Math.random()*(5-1+1)+1);
var player = new Player_1.Player(i, "Player " + i, 100, 72, 0);
this.listOfPlayers.push(player);
}
};
Match.prototype.createMatch = function (matchName, matchType, overs) {
this.createPlayers();
this.matchName = matchName;
this.matchType = matchType;
this.overs = overs;
};
Match.prototype.printPlayerInfo = function (playerName) {
for (var i = 1; i <= 11; i++) {
if (playerName == this.listOfPlayers[i].name) {
this.listOfPlayers[i].printInfo();
}
}
};
return Match;
}());
exports.Match = Match;
31 changes: 31 additions & 0 deletions Day-2/cricket-match/match.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Player } from './Player';
export class Match{

matchName:String;
matchType:String;
overs:number;
listOfPlayers:Player[];
createPlayers(){
this.listOfPlayers = [];
for (let i = 1; i <= 11; i++) {
//let Score = Math.floor(Math.random()*(5-1+1)+1);
let player: Player = new Player(i, "Player "+i, 100,72,0);
this.listOfPlayers.push(player);
}
}
createMatch(matchName:string, matchType:String, overs:number){
this.createPlayers();
this.matchName=matchName;
this.matchType = matchType;
this.overs=overs;
}
printPlayerInfo(playerName:String) {
for (let i = 1; i <= 11; i++){
if(playerName == this.listOfPlayers[i].name){
this.listOfPlayers[i].printInfo();
}
}

}

}
21 changes: 11 additions & 10 deletions Day-2/salary-updater.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use strict";
exports.__esModule = true;
var Organization_1 = require("./Organization");
var salary_upgrader_1 = require("./salary-upgrader");
var org = new Organization_1.Organization('ABC');
org.createEmployees();
org.printEmployeesInfo();
var salaryUpgrader = new salary_upgrader_1.SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
org.printEmployeesInfo();
"use strict";
exports.__esModule = true;
var Organization_1 = require("./Organization");
var salary_upgrader_1 = require("./salary-upgrader");
var org = new Organization_1.Organization('ABC');
org.createEmployees();
org.printEmployeesInfo();
var salaryUpgrader = new salary_upgrader_1.SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
salaryUpgrader.addBonus(org.getEmployeeList());
org.printEmployeesInfo();
1 change: 1 addition & 0 deletions Day-2/salary-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ org.createEmployees();
org.printEmployeesInfo();
let salaryUpgrader: SalaryUpgrader = new SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
salaryUpgrader.addBonus(org.getEmployeeList());
org.printEmployeesInfo();

58 changes: 41 additions & 17 deletions Day-2/salary-upgrader.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
"use strict";
exports.__esModule = true;
var SalaryUpgrader = (function () {
function SalaryUpgrader() {
}
SalaryUpgrader.prototype.incrementSalary = function (percentRaise, empList) {
empList.map(function (emp) {
var oldSalary = emp.getSalary();
var newSalary = (oldSalary * percentRaise / 100) + oldSalary;
emp.updateSalary(newSalary);
});
};
SalaryUpgrader.prototype.addBonus = function () {
};
return SalaryUpgrader;
}());
exports.SalaryUpgrader = SalaryUpgrader;
"use strict";
exports.__esModule = true;
var SalaryUpgrader = (function () {
function SalaryUpgrader() {
}
SalaryUpgrader.prototype.incrementSalary = function (percentRaise, empList) {
empList.map(function (emp) {
var oldSalary = emp.getSalary();
var newSalary = (oldSalary * percentRaise / 100) + oldSalary;
emp.updateSalary(newSalary);
});
};
SalaryUpgrader.prototype.addBonus = function (empList) {
empList.map(function (emp) {
var oldSalary = emp.getSalary();
var bonusAmt = 0;
switch (emp.getRating()) {
case 5: {
bonusAmt = 100000;
break;
}
case 4: {
bonusAmt = 75000;
break;
}
case 3: {
bonusAmt = 50000;
break;
}
default: {
bonusAmt = 0;
break;
}
}
var addBonus = oldSalary + bonusAmt;
emp.updateSalary(addBonus);
});
};
return SalaryUpgrader;
}());
exports.SalaryUpgrader = SalaryUpgrader;
26 changes: 25 additions & 1 deletion Day-2/salary-upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,31 @@ export class SalaryUpgrader {
emp.updateSalary(newSalary);
})
}
addBonus() {
addBonus( empList: Employee[]) {
empList.map(emp => {
let oldSalary = emp.getSalary();
var bonusAmt:number=0;
switch(emp.getRating()){
case 5:{
bonusAmt = 100000;
break;
}
case 4:{
bonusAmt = 75000;
break;
}
case 3:{
bonusAmt = 50000;
break;
}
default:{
bonusAmt =0;
break;
}

}
let addBonus = oldSalary+bonusAmt;
emp.updateSalary(addBonus);
})
}
}
19 changes: 19 additions & 0 deletions Day-2/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html><html>
<head>
<title>Sample HTML page</title>
<script src="salary-updater.js"></script>

</head>
<body>
<div>

<button type="button" onclick="sumofNaturalNum();">Update Salary</button>
<p>please check output in console</p>

</div>

<div id="output">

</div>
</body>
</html>
Loading