Skip to content
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: 3 additions & 0 deletions ooplab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
3 changes: 3 additions & 0 deletions ooplab/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version.
2 changes: 2 additions & 0 deletions ooplab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
30 changes: 30 additions & 0 deletions ooplab/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
52 changes: 52 additions & 0 deletions ooplab/bin/books.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'dart:io';
import 'ooplab.dart';
import 'lists.dart';

class Books {
//attributes
String? bookId;
String? booktitle;
String? auther;
String? type;
//Constructors
Books({this.bookId, this.booktitle, this.auther, this.type}) {}
//Functions
void addBook() {
Map<String, dynamic> book = {
"name": booktitle,
"id": bookId,
"auther": auther,
"type": type,
};
booksListMap.add(book);

print("* book added successfully *");
print("\n");
print("your ID is $bookId ");
main();

stdin.readLineSync(); //for new line after display
}

void displayBook() {
print(" All books ");
for (var element in booksListMap) {
print(" book id is ${element["id"]}");
print(" Title is ${element["name"]}");
print(" auther is ${element["auther"]}");
print(" type is ${element["type"]}");
}
stdin.readLineSync();
main();
}

void deleteBook(String id) {
for (var element in booksListMap) {
if (element["id"] == id) {
booksListMap.remove(element);
}
}
print("* book deleted successfully *");
main();
}
}
38 changes: 38 additions & 0 deletions ooplab/bin/books_function.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'dart:io';
import 'dart:math';
import 'books.dart';
import 'ooplab.dart';

books() {
print(
"Choose option \n 1-Add a book \n 2-display all books \n 3-Delete a book 4-b to go back");
String? bookOption = stdin.readLineSync();
while (bookOption != 'b') {
switch (bookOption) {
case '1':
Random random = Random();
String bookId = random.nextInt(10000).toString();
print("Enter book title");
String? booktitle = stdin.readLineSync();
print("Enter book auther");
String? auther = stdin.readLineSync();
print("Enter book type");
String? type = stdin.readLineSync();
Books book = Books(
bookId: bookId, booktitle: booktitle, auther: auther, type: type);
book.addBook();
case '2':
Books book = Books();
book.displayBook();
case '3':
print("Enter book ID");
String? bookid = stdin.readLineSync();
Books book = Books();
book.deleteBook(bookid!);
default:
print("Please try again");
bookOption = stdin.readLineSync();
}
}
main();
}
41 changes: 41 additions & 0 deletions ooplab/bin/employee.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'dart:io';

class Employee {
List employees = [];

Employee();

addEmployee() {
print("Add employee ID");
int id = int.parse(stdin.readLineSync()!);
print("Add employee name");
String name = stdin.readLineSync()!;
print("Add employee email");
String employeeEmail = stdin.readLineSync()!;
print("Add employee poisiton");
String employeePosition = stdin.readLineSync()!;

Map<String, dynamic> employeeMap = {
"id": id,
"Name": name,
"Email": employeeEmail,
"position": employeePosition,
};

employees.add(employeeMap);
print("Employee added successfully");

stdin.readLineSync();
}

displayinfo() {
for (var element in employees) {
print("-----ID: ${element["id"]}");
print("Name: ${element["Name"]}");
print("Completion: ${element["Email"]}");
print("Position: ${element["position"]}");
print("-------------------------------");
print('\n');
}
}
}
Empty file.
63 changes: 63 additions & 0 deletions ooplab/bin/event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'dart:io';

List<Map<String, dynamic>> enventListMap = [{}];
//Event class display events with it is name,id,date and supervisor name
class Events {
//Attrabutes
String? name;
String? id;
String? supervisor;
String? date;

//constactor
Events({
this.name,
this.id,
this.supervisor,
this.date,
});

//functions
//this function will add new event
addEvent() {
Map<String, dynamic> envent = {
"name": name,
"id": id,
"supervisor": supervisor,
"date": date,
};
enventListMap.add(envent);

print("* Event add successfully *");
print("\n");
print("your ID is $id ");

stdin.readLineSync(); //for new line after display
}

//this function will display all event
displayEvent({required List<Map<String, dynamic>> eventDisplay}) {
for (var element in eventDisplay) {
print(" All Events ");
print(" Event number is ${element["name"]}");
print(" ID is ${element["id"]}");
print(" supervisor is ${element["supervisor"]}");
print(" Date of event is ${element["date"]}");
}
stdin.readLineSync(); //for new line after display
}

//this function will remove event by event id
removeEvent( String eventId) {
Map<String, dynamic> event = {};
for (var element in enventListMap) {
if (element["id"] == eventId) {
event = element;
break;
}
}
//to ensure the number enterd founds
enventListMap.remove(event); // this function remove id
stdin.readLineSync(); //for new line after display
}
}
37 changes: 37 additions & 0 deletions ooplab/bin/events_function.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'dart:io';
import 'dart:math';
import 'event.dart';
import 'ooplab.dart';

events() {
print(
"Choose option \n 1-Add an event \n 2-display all current event \n 3-Delete an event 4-b to go back");
String? eventOption = stdin.readLineSync();
while (eventOption != 'b') {
switch (eventOption) {
case '1':
Random random = Random();
String eventId = random.nextInt(10000).toString();
print("Enter event name");
String? eventName = stdin.readLineSync();
print("Enter supervisor name");
String? supervisor = stdin.readLineSync();
print("Enter event date");
String? date = stdin.readLineSync();
Events event = Events(
name: eventName, id: eventId, supervisor: supervisor, date: date);
event.addEvent();
case '2':
Events event = Events();
case '3':
print("Enter event ID");
String eventId = stdin.readLineSync()!;
Events event = Events();
event.removeEvent(eventId);
default:
print("Please try again");
eventOption = stdin.readLineSync();
}
}
main();
}
2 changes: 2 additions & 0 deletions ooplab/bin/lists.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

List booksListMap = [];
42 changes: 42 additions & 0 deletions ooplab/bin/members.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

import 'dart:io';
import 'dart:math';

class Member {

List memberlist = [];
// constructor
Member();
// function to add member
void addMember() {
print("Enter your name: ");
String? name = stdin.readLineSync()!;
int? id = Random().nextInt(999999);
print("Enter your phone: ");
String? phone = stdin.readLineSync()!;
DateTime? startDate = DateTime.now();
Map<dynamic, dynamic> members = {
"name": name,
"id": id,
"phone": phone,
"startDate": startDate,
};
memberlist.add(members);
}
// function to dispaly member
displaymember(){
for (var element in memberlist) {
print(element.values);
}
}
// function to remove member
removeMember(){
print("Enter id: ");
int id = int.parse(stdin.readLineSync()!);
for (var element in memberlist) {
if(element["id"] == id){
memberlist.remove(id);
}
}
}
}
28 changes: 28 additions & 0 deletions ooplab/bin/ooplab.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dart:io';
import 'books_function.dart';
import 'events_function.dart';

void main() {
print("--------Welcome Admin--------");
print("What do you want to do?");
print("1-Edit books \n 2-Edit empolyees \n 3-Edit members \n 4-Edit events");
String? choice = stdin.readLineSync();
while (choice != 'e') {
switch (choice) {
case '1':
books();
case '2':
//do somthing
case '3':
events();
case '4':
//do somthing
case 'e':
default:
print("Please try again");
choice = stdin.readLineSync();
}
}
print("--------GoodBye--------");
exit(0);
}
Loading