Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

CS once again


  • Please log in to reply

#1
BTPH

BTPH

    Member

  • Member
  • PipPipPip
  • 167 posts
okay im meant to create a C sharp program with 4 classes, a main() class, Item(), ItemOrder() and Order(), theres more info but basically im supposed to submit them as 4 seperate files and have them compile as one program, does anyone have any idea hwo this can be done with CS, coz i sure dont???

cheers,
ben
  • 0

Advertisements


#2
BuRnEr

BuRnEr

    Member

  • Member
  • PipPip
  • 48 posts
my understanding :

you trying to create three different projects and you want to use them in same program?
before i ll give your solution i recommed you that find out about three tier applications?

so now your solution :

1.first project;
create new project in your vstudio and name it firstProject(presentation tier)
this project basically has namespaces, class(which is in this case form class because we are creating windows application),
class deffinition has one constructor, windows designer codes(#region) and
main...
so now just open solution explorer and right clic on project build it.

2.second project;
open solution explorer and right click Solition (not firstProject), choose add new project and name it secondProject(middle tier),
right click on secondProject and build it and no errors ?

open solition explorer again and find form1 under the secondProject(not firstproject) right click on and delete it.
build second project than you ll get an error which says that secondProject doesnot have entry point, remember we deleted form1!!!!since than it doesnt have entery point,
ok now open solution explorer right click on secondProject and choose properties respectly. and change the "Output Type" to class library by default it is windows application for windows app, and ok.
build secondproject again no error, because the second project is a "dll" and it doesnt need entery point....

3.third project
open solution explorer and right click Solition choose add new project and name it thirdProject(data tier)
right click on secondProject and build it and no errors ?
open solition explorer again and find form1 under the thirddProject(not firstproject) right click on and delete it. And right click on thirdproject, properties, change the output type to class library again ok
and build thirdProject, no errors

so as you can see in your solution explorer there are three project, one excutable and two "dll"

not done yet, lets add our classes now
right click second project add, add class and name(i name it "secondPC" it whatever you like
there is a class is created and it has one constructor in it,
do same thing for thirdProject(i name it "thirdPC"),

you already have a class the firstproject you can rename it or you can add more classes,
you also can add more than one classes other projects too,

now we have our three different projects with containing one class,

ok than our architecture is ready but there is a missing thing how we can link them together, (like you have network, which has webserver side(where your first project sits(presentation)), application server side(where your second project sits(middle=business logic=functional methods), and database server side(where your third prject sits(data tier),
so the problem how to link them together, with a cables :tazz: yes thats right physically we need cable, router, switch, firewalls whatever this is network addmins job, but we still need to link our applications together how lets see how;

open solition explorer again;
right click on firstproject choose add Reference... in the new opened window choose projects tab (than you ll see two projects second and third projects) double clic secondProject and than ok,

right click on secondproject choose add Reference... in the new opened window choose projects tab and double clic thirddProject and than ok,

Now open form under the first project right click on form and choose view code,

add this to name space=
using secondProject;

add this in class definition
private secondPC pointer_to_secondProject;//declare pointer for second proj

and add this to the constructor which has one item in it "InitializeComponent();"
//here
pointer_to_secondProject=new secondPC();

Open secondProject class on your vstudio and add same places

add this to name space=
using thirdProject;

add this in class definition
private thirdPC pointer_to_thirdProject;//declare pointer from second project to third proj

and add this to the constructor which has one item in it "InitializeComponent();"
//here
pointer_to_thirdProject=new thirdPC();

compile your projects and done now
you have three projects under the one solition;

take care
BuRnEr
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP