import { Injectable } from "@angular/core";
export interface Course {
id?: string;
name?: string;
description?: string;
price?: number;
quantity?: number;
inventoryStatus?: string;
category?: string;
rating?: number;
}
@Injectable()
export class CourseService {
stockStatus: string[] = ["InStock", "OutOfStock", "StockShortage"];
courseNames: string[] = [
"DSA Self Paced",
"System Design",
"Operating System",
"Computer Networks",
"DBMS",
"C++ STL",
"Competitive Coding",
"DSA Self Paced",
"System Design",
"Operating System",
"Computer Networks",
"DBMS",
"C++ STL",
"Competitive Coding",
"DSA Self Paced",
"System Design",
"Operating System",
"Computer Networks",
"DBMS",
"C++ STL",
"Competitive Coding",
"DSA Self Paced",
"System Design",
"Operating System",
"Computer Networks",
"DBMS",
"C++ STL",
"Competitive Coding"
];
generateCourse(): Course {
const course: Course = {
id: this.gfgId(),
name: this.gfgName(),
description: "Course Description",
price: this.gfgPrice(),
quantity: this.gfgQuantity(),
category: "Course Category",
inventoryStatus: this.gfgStatus(),
rating: this.gfgRating()
};
return course;
}
gfgId() {
let myid = "";
let guess = "ABCDEFRST56789";
for (var i = 0; i < 10; i++) {
myid += guess.charAt(Math.ceil(Math.random() * guess.length));
}
return myid;
}
gfgName() {
return this.courseNames[(Math.floor(Math.random() * Math.floor(20)))];
}
gfgPrice() {
return Math.floor(Math.random() * Math.floor(99) + 1);
}
gfgQuantity() {
return Math.floor(Math.random() * Math.floor(85) + 1);
}
gfgStatus() {
return this.stockStatus[(Math.floor(Math.random() * Math.floor(2)))];
}
gfgRating() {
return Math.floor(Math.random() * Math.floor(4) + 1);
}
}