Skip to content

bonus #3

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
3 changes: 2 additions & 1 deletion Day-2/Employee.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use strict";
exports.__esModule = true;
var Employee = (function () {
function Employee(id, name, salary) {
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);
Expand Down
5 changes: 4 additions & 1 deletion Day-2/Employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ 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}`);
Expand All @@ -16,5 +18,6 @@ export class Employee {
getSalary() {
return this.salary;
}

}

5 changes: 4 additions & 1 deletion Day-2/Organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Organization = (function () {
}
Organization.prototype.createEmployees = function () {
for (var i = 1; i <= 10; i++) {
var emp = new Employee_1.Employee(i, 'A' + i, i * 1000);
var emp = new Employee_1.Employee(i, 'A' + i, i * 1000, this.generateRating());
this.listOfEmployees.push(emp);
}
};
Expand All @@ -21,6 +21,9 @@ var Organization = (function () {
Organization.prototype.getEmployeeList = function () {
return this.listOfEmployees;
};
Organization.prototype.generateRating = function () {
return Math.ceil(Math.random() * 10);
};
return Organization;
}());
exports.Organization = Organization;
8 changes: 6 additions & 2 deletions Day-2/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { Employee } from './Employee';
export class Organization {
name: string;
listOfEmployees: Employee[];

constructor(name: string) {
this.name = name;
this.listOfEmployees = [];
}
createEmployees() {
for (let i = 1; i <= 10; i++) {
let emp: Employee = new Employee(i, 'A' + i, i * 1000);
let emp: Employee = new Employee(i, 'A' + i, i * 1000,this.generateRating());
this.listOfEmployees.push(emp);
}
}
Expand All @@ -21,5 +22,8 @@ export class Organization {
getEmployeeList() {
return this.listOfEmployees;
}
generateRating(){
return Math.ceil(Math.random() * 10);
}

}
}
2 changes: 2 additions & 0 deletions Day-2/salary-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ org.printEmployeesInfo();
var salaryUpgrader = new salary_upgrader_1.SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
org.printEmployeesInfo();
salaryUpgrader.addBonus(1000, org.getEmployeeList());
org.printEmployeesInfo();
3 changes: 3 additions & 0 deletions Day-2/salary-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ let salaryUpgrader: SalaryUpgrader = new SalaryUpgrader();
salaryUpgrader.incrementSalary(10, org.getEmployeeList());
org.printEmployeesInfo();

salaryUpgrader.addBonus(1000, org.getEmployeeList());
org.printEmployeesInfo();

9 changes: 8 additions & 1 deletion Day-2/salary-upgrader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ var SalaryUpgrader = (function () {
emp.updateSalary(newSalary);
});
};
SalaryUpgrader.prototype.addBonus = function () {
SalaryUpgrader.prototype.addBonus = function (bonusAmount, empList) {
empList.map(function (emp) {
console.log(emp.rating);
if (emp.rating > 5) {
var newSalary = emp.getSalary() + bonusAmount;
emp.updateSalary(newSalary);
}
});
};
return SalaryUpgrader;
}());
Expand Down
10 changes: 8 additions & 2 deletions Day-2/salary-upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ export class SalaryUpgrader {
emp.updateSalary(newSalary);
})
}
addBonus() {

addBonus(bonusAmount : number , empList:Employee[]) {
empList.map(emp =>{
console.log(emp.rating);
if(emp.rating > 5){
let newSalary = emp.getSalary() + bonusAmount;
emp.updateSalary(newSalary);
}
})
}
}
57 changes: 57 additions & 0 deletions do-it/.angular-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "do-it"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
13 changes: 13 additions & 0 deletions do-it/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions do-it/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db
28 changes: 28 additions & 0 deletions do-it/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# DoIt

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0-rc.2.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
14 changes: 14 additions & 0 deletions do-it/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DoItPage } from './app.po';

describe('do-it App', () => {
let page: DoItPage;

beforeEach(() => {
page = new DoItPage();
});

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
});
});
11 changes: 11 additions & 0 deletions do-it/e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { browser, element, by } from 'protractor';

export class DoItPage {
navigateTo() {
return browser.get('/');
}

getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
19 changes: 19 additions & 0 deletions do-it/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016"
],
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types":[
"jasmine",
"node"
]
}
}
44 changes: 44 additions & 0 deletions do-it/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Loading