Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,
I want to implement oops ,let say there exist two different user user1(Accountant)
and user2(client)

Each user should print report on the basis of there roles.(ie
1) Accountant should able to print report with header footer and invoice. And
2 ) Client user should print report without header,footer and invoice).
3) and in future there may come some different requirement.

How to follow oops to accomplished the above task.

I have a plan like below

public inferface IReport
{
 void print();
}

public class headerfooterInvoice{

}

class clsAccountant : IReport
{
  void header()
  {

  }
   
  
  overide print(){
// get data from sql 
  
}

 void footer()
{}

void invoicereport()
{
}
}

class clsClient : IReport
{
  overide print()
{
  // get data from sql 
}
}

class static clsfactory
{
  public static IReport getReport(int usertype)
{
   IReport objireprt
  if(usertyp="1") // accountant
{
  objireprt=new clsAccountant();
}
else
{ 
  objireprt=new clsClient();
}
return objireprt;
}
} 



button click code here
IReport objreprt;
objreprt= clsfactory.getReport(session["usertype"]);
objreprt.print();



how will i call header method,footer method,and invoice method ,
I need some logic in which i dont need to change my client code if in future
there come some different scenarios.
Plz someone guide me which design pattern should i follow .
Posted
Updated 25-Oct-14 8:13am
v4
Comments
Sergey Alexandrovich Kryukov 26-Oct-14 0:43am    
All these exercises make little to no sense. In what sense a use can be a "report"? Before writing some interfaces and classes, you need to model reality adequately to some goals, not just to make things look as OOP. There is no a glimpse of OOP here. The question simply lacks subject; this is a question about nothing.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900