MG-Rover.org Forums banner

1 - 20 of 20 Posts

·
Registered
Joined
·
13,101 Posts
Discussion Starter #1
is there anybody who is good with c++ cause im stuck on my coursework and need help, ive got a post on cprogramming.com, but there not that lively.
ill give more details if sombody replies.
thanks
 

·
Registered
Joined
·
8,105 Posts
im not so good on C++, you tried asking on experts-exchange.com? I'm a registered expert on there and you can normally get an excellent response pretty quickly
 

·
Registered
Joined
·
14,750 Posts
What's the problem? Post it up anyway.

There are quite a few v good programmers on here.

Is it .Net version?

You have to pay for experts exchange, i use a friends account :shh:
 

·
Registered
Joined
·
1,195 Posts
My observations would be, if you're using CPP why use structs why not use an object? Then have methods for entry/removal of the booking slots, and track these as items are added/removed...?

eg psuedocode:

reserveSlot (weekNumber, slotNumber) {
...
updateUsage (weekNumber, slotNumber);
}

removeSlot (weekNumber, slotNumber) {
...
decreaseUsage(weekNumber, slotNumber);
}

You could store the results in an array, eg week1Array[slotNumber]++; or even better a 2D array or database and it will scale then, it you decide to track an extra month etc.

...or am i missing the point completely lol. Sorry its rough, im more Java than cpp, but it does seem to me to make more sense to use an object than a struct.
 

·
Registered
Joined
·
13,101 Posts
Discussion Starter #8
sorry not done any object orientated yet. will do in 2nd year though. but at the mo my program is about 1k lines long, and deadline is wed. so have to finish it how it is if you know what i mean.
 

·
Registered
Joined
·
1,195 Posts
OK understood, but still the essence of what you are trying to do, if I understand correctly, is count which slots are used for a given week, against the total number of available slots, is that correct?
 

·
Registered
Joined
·
13,101 Posts
Discussion Starter #10
bang on. 4 weeks 6 days 4 daily slots. people book willy nilly, and i need usage stats for each matching slot. i.e. mon period 1 has 66% full. of total 9 etc.
 

·
Registered
Joined
·
1,195 Posts
dac said:
bang on. 4 weeks 6 days 4 daily slots. people book willy nilly, and i need usage stats for each matching slot. i.e. mon period 1 has 66% full. of total 9 etc.
total 9? How? There are four slots per day...

Anyway, not having seen your code, I assume there is somewhere that sets the status of a slot? ie if its booked or not. If so, then can you add a counter to this method/function. Its easier & simpler to track the stats on the fly, rather than try and tally them up at the end (unless you were using a DB).

Does that make sense?
 

·
Registered
Joined
·
13,101 Posts
Discussion Starter #12
understood. this is surposed to be a database solution, the example data is for jan and feb 06, so there is 9 mons and tues.
the slots are shown as booked if theres sommin in em. so its just for whats in the array'd structs that i need stats for. if you get me.
 

·
Registered
Joined
·
1,195 Posts
Er ok.

Not sure why you're using a memory array if this is a DB solution, far easier to just chuck all the data into the DB, then let the DB calc up the stats you need.

Anyway, good luck with it. Sorry I couldn't be more help.
 

·
Registered
Joined
·
13,101 Posts
Discussion Starter #14
thats ok. im sure sombody else will have read this, btw everbody in my class has used access for theres, but i wanted to be different and programme it myself. every thing is working fine except this.
 

·
Registered
Joined
·
1,195 Posts
Depending on how you've got your array structured, you can probably just loop over it keeping a tally as you go, as you know every nth element is monday etc, pretty much as bumfluffs post on cpprogramming.com.

Do you get extra points for reinventing the wheel? ;) j/k
 

·
Registered
Joined
·
13,101 Posts
Discussion Starter #16
it deffinately gives a better impression to the examiner. as its indisputable that its my work. also everybody else is copying each other! which i dont want to do.
heres my solution so far, it seems to be working aswell.

for(i=0; i<number_of_bookings; i++){

switch(bookings.day)
{
case 1://week 1 mon
switch(bookings.time)
{
case 1: monp1 += 1; break;
case 2: monp2 += 1; break;
case 3: monp3 += 1; break;
case 4: monp4 += 1; break;
break;
}
case 2://week 1 tue
switch(bookings.time)
{
case 1: tuep1 += 1; break;
case 2: tuep2 += 1; break;
case 3: tuep3 += 1; break;
case 4: tuep4 += 1; break;
break;
}
case 3://week 1 wed
switch(bookings.time)
{
case 1: wedp1 += 1; break;
case 2: wedp2 += 1; break;
case 3: wedp3 += 1; break;
case 4: wedp4 += 1; break;
break;
}
case 4://week 1 thu
switch(bookings.time)
{
case 1: thup1 += 1; break;
case 2: thup2 += 1; break;
case 3: thup3 += 1; break;
case 4: thup4 += 1; break;
break;
}
case 5://week 1 fri
switch(bookings.time)
{
case 1: frip1 += 1; break;
case 2: frip2 += 1; break;
case 3: frip3 += 1; break;
case 4: frip4 += 1; break;
break;
}
case 6://week sat
switch(bookings.time)
{
case 1: satp1 += 1; break;
case 2: satp2 += 1; break;
case 3: satp3 += 1; break;
case 4: satp4 += 1; break;
break;
}
}
}

cout << "monday period 1 : " << (100/9) * monp1 << endl;
cout << "monday period 2 : " << (100/9) * monp2 << endl;
cout << "monday period 3 : " << (100/9) * monp3 << endl;
cout << "monday period 4 : " << (100/9) * monp4 << endl;
cout << "tuesday period 1 : " << (100/9) * tuep1 << endl;
cout << endl;
 

·
Premium Member
Joined
·
31,560 Posts
personally, I think it would work against you. As a programmer you shouldn't look to reinvent the wheel, rather you use the tools you have to hand to solve the problem as quickly as efficiently as you can.

Reinventing the wheel, whilst it could show skill to an examiner, it wouldn't be good as far as a manager is concerned - I just hope the examiner doesn't think along those lines!

Good luck though!
 

·
Registered
Joined
·
30,859 Posts
i have to agree steve, surely the whole point is to get the end result as quickly and as cleanly as possible.....
 

·
Registered
Joined
·
1,063 Posts
I'd agree with the last 2 posts. It depends whether your aim is to get a degree or learn. There is a difference...The marker of an assignment is only concerned that what you've done meets the spec, if it can be done using Access (and produce the required functionality) then deffo use access.....

I'm in my 3rd year now and all of my assigments have been based on templates (reports, plans, office automation (eg MSP, Netbeans, MS Office)). On a recent Proj Mgmt assignment we had guys drawing cascade bar charts by hand, which is great but when you come to the bit where you have to reschedule tasks it takes a long time, far easier to use MSP, takes all of 1 min to re-schedule.

Although I'm doing a computing degree I hate the programming side (Java) so I can't help on this thread except question what you want out of the degree. A low risk approach (i.e. use access) where you can easily achieve 70+% or a high risk approach (i.e. C++) and risk failing the assignment and module, then re-taking and being capped at 40%.

Lee

PS I hope you find a solution......
 

·
Registered
Joined
·
1,195 Posts
..and in the real world, ie on a project with deadlines, you'd not be too popular if you started rebuilding your own version of everything... I would hope that university reflects at least some of the pressures and constraints that will be imposed as a professional developer.
 
1 - 20 of 20 Posts
Top