My Programming Portfolio
Abstract Class C Sharp Code
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
using
System.Threading.Tasks;
namespace
my_inheritance
{
class Program
{
static void Main(string[] args)
{
car_client my_car_client = new
car_client { name = "Michael", Place = "Estero bay
Chevrolet", Date = "12-31-14", Car_year =
2006,Model="saturn ion"};
printDetails(my_car_client);
}
private static void printDetails(client
new_client)
{
Console.WriteLine(new_client.format_return());
}
}
abstract class client
{
public String name { get; set; }
public String Place { get; set; }
public String Date { get; set; }
public abstract string format_return();
}
class car_client : client
{
public int Car_year { get; set; }
public string Model { get; set; }
~car_client()
{
Console.WriteLine("The Car
object has been destroyed");
}
public override string format_return()
{
return String.Format("The name
of the patient is {0} and the place is {1} and the date is {2} the year of the
car is {3} and the model of the car is {4}", this.name, this.Place,
this.Date, this.Car_year, this.Model);
}
}
class dentist_client : client
{
public string problem_with_mouth { get;
set; }
public int patient_number { get; set; }
~dentist_client()
{
Console.WriteLine("The tooth
has been destroyed");
}
public override string format_return()
{
return string.Format("The name
of the patient is {0} and the place is {1} and the date is {2} the problem with
the mouth is {3} and the patient number is {4}", this.name, this.Place,
this.Date, this.problem_with_mouth, this.patient_number);
}
}
}
Results
Concepts Used
- Inheritance
- Abstract Class Definition(using abstract keyword in C Sharp to set up a base class)
- Data Encapsulation
- Destructors
- Constructors(setting of the instance variables for each object)
- String Formatting in C Sharp
class
job_description(object):
def __init__(self,name,occupation,salary):
self._name=name
self._occupation=occupation
self._salary=salary
def __del__(self):
print "Destructor Started"
#This is for when you get a bonus
new_salary=lambda self,raise_amount:
"%s your new salary as an %s is %s
"% (str(self._name),str(self._occupation),str(self._salary+raise_amount))
class
Computer_programmer(job_description):
def
__init__(self,certifications,language,name,occupation,salary):
self._certifications=certifications
self._language=language
self._name=name
self._occupation=occupation
self._salary=salary
class
Nurse(job_description):
def
__init__(self,certifications,name,occupation,salary):
self._certifications=certifications
self._name=name
self._occupation=occupation
self._salary=salary
class
Engineer(object):
def
__init__(self,certifications,heaviest_truck_driven,name,occupation,salary):
self.__certifications=certifications
self.__heaviest_truck_driven=heaviest_truck_driven
self.__name=name
self.__occupation=occupation
self.__salary=salary
one_line_job_description=lambda
self:"Your name is %s and you are %s who makes %s a year ,your
certification is %s and the heaviest truck you have driven is %s" %
(self.__name,self.__occupation,self.__salary,self.__certifications,self.__heaviest_truck_driven)
it_job=job_description("Michael","Programmer
Analyst",38000)
it_job.new_salary(2000)
del it_job
programmer=Computer_programmer("A+","C#","Michael","Senior
C# Developer",80000)
print
programmer.new_salary(20000)
my_nurse=Nurse("Heart
Health","Martha","Cardiologist",60000)
print
my_nurse.new_salary(2000)
Construction_engineer=Engineer("Big
Rigs","7 Tons","Joe","Big Rig Truck
Driver","100000")
print
Construction_engineer.one_line_job_description()
Concepts Used
- Inheritance
- Data Encapsulation(Using Public for the Functions and Protected and Private for the instance variables)
- Destructors
- Constructors
