Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // retrieve from database
- // existing functions:
- // DatabaseFeature (class)
- // - connectToDatabase
- // 1. GET EMPLOYEES
- // connect to database
- // get employees
- // 2. UPDATE EMPLOYEE
- // connect to database
- // update employe
- using System;
- using System.Collections.Generic;
- namespace Demoabstraction
- {
- // abstract class
- abstract class DatabaseFeature
- {
- // abstract method
- public abstract int connectToDatabase();
- }
- // square class inherting
- // the Shape class
- class GetEmployees : DatabaseFeature
- {
- public override int connectToDatabase()
- {
- // connect to database stuff
- throw new NotImplementedException();
- }
- public int getEmployeeCount()
- {
- connectToDatabase();
- int employeeCount = 100; // dummmy
- return employeeCount;
- }
- public List<string> getEmployeeNames()
- {
- connectToDatabase();
- List<string> employees = new List<string>();
- //retrieve employee names
- return employees;
- }
- }
- class UpdateEmployee : DatabaseFeature
- {
- public override int connectToDatabase()
- {
- // connect to database stuff
- throw new NotImplementedException();
- }
- public void updateEmployeeName(string firstName, string lastName, string middleName)
- {
- connectToDatabase();
- // update employee's name
- }
- public void updateEmployeeCredentials(string username, string password)
- {
- connectToDatabase();
- // update employee's credentials (username, password)
- }
- }
- // Driver Class
- class SampleClass{
- // Main Method
- static void Main(string[] args) {
- UpdateEmployee update = new UpdateEmployee();
- // calling the method
- GetEmployees employees = new GetEmployees();
- }
- }
- }
Add Comment
Please, Sign In to add comment