Wednesday, March 31, 2010

OOP344 project & BVedit

Its been a while since I blogged and ive actually done some stuff recently so I figured id blog about it.

Up till now our team has been in shambles so to speak and weve been slacking. Not pointing the finger at anyone as Im just as much to blame. So the team has been working pretty hard in the last 2 weeks or so to catch up to the rest of the class in regards to the project, and I think its safe to say were caught up finally. It also made it a bit more difficult because 2 of our team members dropped the course.

On monday Fardad assigned BVedit to the class which is to be done by thursday. I wasnt too busy with other classes so I figured id attempt to do it. Most of the coding was pretty straight forward and went smoothly. Alot of it was dealing with pointer to functions and passing them different error message flags(atleast thats what I think they are). There were 2 seperate functions, validate and help. The help message function would be called to show a help message in a certain field before editing is done, or to clear the help message before editing is terminated. The validate function was there to ensure the data being entered was valid, and if it wasnt, would continue to call bedit() untill the data returned was valid. It was a pretty fun function to code, even tho I had some minor problems.

The problems I had suprisingly came in the 2 constructors of BVedit. I dont know if my mind just wasnt working or what but I didnt understand what exactly the constructors were looking for in regards to the pointers to function. I understood that I had to pass corresponding attributes to BEdit, but i didnt understand how the pointers to functions were suppose to work. As i couldnt find anyone from my team to help me on IRC, luckily someone else from my class was on and was able to help me. The_wonderer on IRC was able to clarify some stuff for me and help me understand exactly what was needed. Thanks again The_wonderer I really appreciate it!

Anyways its time to go and some more and get ready for the upcoming test.

Until next time,

dAve

Wednesday, February 24, 2010

Assignment 1 done.... I think

Well I think almost everything is done for assignment 1, which is relieving. I recently just finshed adding my complex functions to the tags folder as Ive sorta been putting it off for sometime now. Not because im lazy, but because I was still hazy on what exactly tags were for. During class on monday a couple of my group members clarified exactly what it was for. As far as the simple functions go, I dont know if were supposed to make a folder in tags for each of those aswell. I didnt because it seemed sort of pointless for such small functions, but it will probably come back to bite me in the a**.

It was also nice to see that the majority of my group have done what they set out to do. I was actually going to come home and finish doing the linux and mac parts of my simple functions tonight, but it looks like Umar beat me to it!

Thanks for doing those Umar, really appreciate it.

So far this semester has been pretty good. Ive learnt quite a bit in OOP344 so far. Its nice having the CDOT planet feed to look at what everyone is doing in the school. Its sorta inspiring looking at what people a couple of semesters ahead of me are doing and seeing them post blogs about it. Its also nice to look at what problems the rest of my class is having and how they resolved it. Being able to look at a problem through someone elses perspective really helps, especially when you have been stairing at code for hours.

Anyways time to take a much needed rest after some midterms.

Until next time,

dAve

Thursday, February 18, 2010

MyPrint Challenge

Here is my code for the MyPrint challange that was assigned today in class.

The code is as follows:

void main ()
{
MyPrint("int %d, char %c, string %s, hex %x, float %f", 2, 'A', "hello", 16, 12.34567);

}

int MyPrint(char* str, int a, char b, const char c[], int d, float f)
{
int i = 0;

while (str[i] != '\0')
{
if (str[i] == '%' && str[i+1] == 'd')
{
i++;
i++;
putint (a);
}
if (str[i] == '%' && str[i+1] == 'c')
{
i++;
i++;
_putch (b);
}
if (str[i] == '%' && str[i+1] == 's')
{
i++;
i++;
_cputs (c);
}
if (str[i] == '%' && str[i+1] == 'x')
{
i++;
i++;
puthex (d);
}
if (str[i] == '%' && str[i+1] == 'f')
{
i++;
i++;
putdub (f);
}
_putch(str[i]);
i++;
}

_getch();

return 0;
}

void puthex(int val)
{
char str[20] = "";
int i = 0, num;
while(val != 0)
{
str[i] = (val % 16) + 48;
val = val/16;
i++;
}

for (i = 0;i <= 19;i++)
{
if (str[i] != '\0')
{
num = str[i] - 48;
if (num > 9)
str[i] += 7;
}
}

for (i = 19; i >= 0;i--)
{
if (str[i] != '\0')
_putch(str[i]);
}
}
void putdub (double val)
{
char buff [20] = "";
int asdf = val;
val = val - asdf;
int i, j, start;
j = 0;

for (i = 10000; i >= 1;i = i/10)
{
if (asdf >= i)
{
start = asdf/i;
asdf = asdf % i;
buff [j] = start + 48;
j++;
}
}
buff [j] = '.';
j++;

asdf = val/0.01;
buff [j] = (asdf/10) + 48;
j++;
buff[j] = (asdf%10) + 48;

_cputs (buff);
}

void putint(int val){
char temp[20] = "";
int i = 0;
int j = 0;
int length = 0;
int scale = 1;
if (val == 0)
_putch('0');
else{
for (i = 1, length = 0; val / i != 0 ; i *= 10, length++);
if (val > 0) {
for (i = 0; i < length; i++){
scale = 1;
for (j = 0; length - j > i + 1; j++)
scale *= 10;
temp[i] = (val / scale) % 10 + 48;
}
temp[i] = '\0';
}
else {
val *= -1;
temp[0] = '-';
for (i = 0; i < length; i++){
scale = 1;
for (j = 0; length - j > i + 1; j++)
scale *= 10;
temp[i+1] = (val / scale) % 10 + 48;
}
temp[i+1] = '\0';
}
}
_cputs (temp);
}

Since I never did the previous challenge, I was looking through the CDOT planet feed for someone who did the first one, and luckily I found one. I used Shengwei's solution. I hope this is acceptable considering it is an open source subject. Anyways thanks for posting your code shengwei, made my life a little easier!

As far as the code that I wrote goes, it was pretty straight forward. I decided the easiest way to go about it was to use _putch and _cputs for displaying single characters and strings. The hex function was pretty simple as far as coding goes, although it took me a while to remember how to convert from decimal to hex, its been a while ahah. The decimal function was the trickiest for me for some reason. I kept thinking of other ways to do mid way through writing the code for the function, causing me to stop and rethink my approach many times.

Any ways hope this is what your looking for Fardad. I look forward to 10% on the test :D

Monday, February 8, 2010

OOP344 Assign 1 so far

Well its been a while since I blogged and figured I may aswell drop a couple lines on my progress through assignment one thus far.

As it stands, I havnt heard much from my team other then Carolyn who I discussed the project with briefly before the weekend. I dont know where everyone else is on there functions, or what functions there even doing for that matter. I hope everythings going well...

As far as my part is concerned it went off without a hitch. I completed both the bio_getch(), and bio_move() simple functions. Didnt take much as the code was supplied by the teacher, but I made a point of understanding what was going on in each of the functions. As far as complex functions go, I finished bio_display() on my own in probably one of the least efficient ways. But its done! The only minor problem I was having was getting .length() to work with the string being passed to the function. I dont know why, but it wasnt working for me. So I decided to take the long way around the problem and pass it through a while loop with a counter to determine the length of the string each time its passed through the function. Hardly efficient. If anyone reads this and has encountered the same problem/has a solution please let me know!

As I said before I hope my group is doing there parts. As if I find out today no one has done there parts, im going to have to try and pick up the slack tonight. Seeing as our first release is due tomorrow, its something I could really do without. The only other person ive seen commit any code what-so-ever is Carolyn, who put up the files for the program, and finished her simple function (bio_clrscr()). Its nice to see someones done something!

I think im going to attempt to tackle another complex function just incase no ones done anything.

Thats all for now,

dAve

Thursday, January 28, 2010

IRC Meeting 1

Well on tuesday our team (TEAM TEAM) had our first meeting with fardad over IRC. Despite one member being late, everyone showed up which was good to see. The meeting itself was quite laid back as it was over IRC. Fardad essentially went over what was common practice for IRC, the lingo, how meetings are held, and so on. To say the least it was a good first meeting. I like the idea of being able to sit in the comfort of my own home and have a meeting with my whole group, aswell as the teacher. Doing this makes it much easier for communication between our group. Having IRC also gives all of us one common place to discuss our projects aswell as casually interact.

On another note, our group has grown considerably. We started out with 3 of us originally, and its turned into 6 now (possibly 7 as I just got an email from someone requesting to join our group). everyone thus far out of the 6 of us tends to seem quite easy going, which is definatly a plus. Also its nice to see that everyone in my group attends class regularly aswell. All in all I have high hopes for our group and am pretty excited to start the first assignment!

Well fardad is talking about how define works and so on, so I should probably pay attention.

Thats all for now,

dAve

Monday, January 18, 2010

Class canceled....

Well i was all hyped up for some OOP344 today, but unfortunately the class was canceled. Hopefully Fardad is better by next class, or else i dont know what Im going to do with myself.....

Patiently waiting,

dAve

Monday, January 11, 2010

And so it begins...

Well today was the first day back to classes after an almost month long break, and surprisingly enough, im glad to be back. Mondays are by far my worst day, being about 7 hours straight. But despite the long hours at school, it looks like class is going to be pretty entertaining. Now to get to how this blog came to be.

During my first class of OOP344, our teacher proceeded to tell us that he was trying something different this semester, and that we would be the first full semester hes tried this idea on. He explained how the class would be focusing on open source concepts, and how we would be undertaking programming projects 20x's bigger then we have in OOP244. He also told us that all projects would be done in groups, which is both a sigh of relief, and a potential future full of grief. I say this because I have worked in groups in the past which, sadly, have mostly ended in arguements and someone slacking off. Im going to attempt to stay optimistic about this and hope for the best!

All in all, im quite excited about this semester, the teacher seems to be quite entusiastic about the material and encourages class participation, quite different from the usual programming class im used to. Cant wait to get more in depth into OOP344.

Until next time,

dAve