Friday, December 25, 2009

Punta Cana++

I just got back from a 1 week vacation in Punta Cana. It was awesome! I did NOT work on the OOP344 as2, but I did study some C++. My only reading material was C++ for dummies.

Most interesting to me was a section where the author discusses the differences between passing objects/classes into functions by copy, pointer, and reference. I have sometimes wondered "why use pointers when reference is so similar, and the syntax is not as confussing?" I plan to blog about this separately.

As for the assignment, I hope to spend December 26th getting caught up on what my group did while I was swimming in the ocean.

Thursday, November 26, 2009

abstract base class- pure virtual

IO_Field is an abstract base class and has some pure virtual functions, indicated by the
= 0; at the end.

virtual void display(void)const = 0;
virtual int edit(void) = 0;
virtual bool editable(void)const = 0;
virtual void set(const void *) = 0;
virtual void set(IO_Form* owner) = 0;

When functions are pure virtual, they should not have any other code (in the .cpp file). Also, when a class is an abstract base class with pure virtual functions, whatever classes that INHERIT the abstract base class (with pure virtual functions) MUST have code (usually in the .cpp) for those (pure virtual) functions (in the abstract base class).

Wednesday, November 25, 2009

(tag) && (!trunk || !branch);

Team Funktion had an in-person meeting last night in the Seneca@York library.

Our tag folder on SVN has been updated so that it is compiling. A vs project has been added to the tag folder. Eric is currently working on getting IO_Label to display inside the form.

The branches folder is messy (my fault) and apparently, the trunk is not compiling (not my fault). If it's ok with everybody, when we get our new SVN (coming soon) we should work with the compiled code that is in our tag folder.

Perhaps somebody can go and delete content in our branches folder. I don't know how.

blog+=blog;

Fardad said that as part of the final evaluation, we will each have to grade each other anonymously.

It is important to remember that if you are not sending emails or blogging or updating your user.txt file on SVN, than the other team members have no way of grading your participation except to figure out what you coded. That's really tough for me because I can barely figure out what I coded.

So remember the following...

1) BLOG! Even if you have little to report. A few words on a regular basis will remind the team that you are still with them.

2) Update your user.txt file on SVN. Even if you are not committing code. This is another place that Fardad will look when he is grading you.

If your team members can read your blog, they will be more inclined to grade you favorably.

Assigned Class

Remember that having an assigned class does not mean you have to write it by yourself. For example, I was assigned IO_Form, but Neda put a lot of work into it. Last night Eric and I were working together to debug the IO_Label display().

Having an assigned class means that you are responsible for making sure it works when we are submitting, but everybody should be involved with all parts of the project. Even if all you do is walk-through it.

If you are waiting on another class in order to proceed, than perhaps you should offer to help out. You can even start by giving the class some basic functionality so you can move forward.

You can also be involved by optimizing other parts of the code. Just be sure to discuss it with the person in charge before you commit any revision.

Wednesday, November 18, 2009

OOP344 Assignment 2 - My Current Status

I started working on Assignment 2 last weekend. My responsibility is io_form and I am going to to use the Linked List method. After spending some time trying to get started, I gave up and just reviewed Linked Lists instead.

On Tuesday November 17th, Neda and I met with Fardad to discuss some basics about Assignment 2. I recorded the meeting. You can download it here.

Tonight I will be meeting with a tutor in the learning center to help me get started with some actual code.

Saturday I am coming to the Seneca library to build a main that can test the io_form and io_field.

Thursday, November 12, 2009

OOP344 Assignment 2 - makefile

I am using a makefile to work with my assignment 2 on the mac, rather than compile in xcode. Since the program is text-based, I'm finding it easier to view in the terminal.

Earlier I had posted an issue I was having with my makefile. The issue is resolved now. You can view my makefile below.

# makefile for OOP344 Assignment 2

# By: Ljubomir Gorscak
# November 12, 2009
#

# build main
binaries: main

# links the binary components for main
main: main.o ciol.o io_frame.o lj_field.o
g++ main.o io_frame.o lj_field.o ciol.o -lcurses -o main

# recompiles main.cpp if anything changed
main.o: main.cpp ciol.h io_def.h io_frame.h lj_field.h
g++ -c main.cpp

# recompiles ciol.c if anything changed
ciol.o: ciol.c
gcc -c ciol.c -lcurses

# recompiles io_frame.cpp if anything changed
io_frame.o: io_frame.cpp
g++ -c io_frame.cpp

# recompiles lj_field.cpp if anything changed
lj_field.o: lj_field.cpp
g++ -c lj_field.cpp


# clean for Assignment 3
# clean.mak

# removes any file ending with .o and main from the current directory
clean:
rm -f *.o main

Wednesday, November 11, 2009

OOP344 Assignment 2 - Thoughts on team work

In my humble opinion, it would be very difficult to understand this project as a whole if each team member only writes the class assigned to them. There are a few ways that we can learn from each other.

1) Ask for help from team members
2) Offer to help other team members
3) Walk through other team members classes and offer to optimize their code (make sure you ask first!)

Sunday, November 1, 2009

Question from previous OOP344 test

I don't understand this question...

"Write a program that prints the number of environment variables of the operating system."

Thursday, October 29, 2009

Oct 29, 2009 IRC Meeting with Fardad - Questions

For today's meeting I hope to clarify the file hierarchy for assignment 2. Specifically, I am a little confused about #includes, and how linking will occur with all the .cpp and .h classes separated in they're own folders.

I also have questions about what state the .cpp and .h files should be in. Many of the descriptions for assignment 2 classes listed on the wiki are incomplete, or no description at all.

My mind will be at ease once I am sure all the files are placed where they should be, and we get a proper build.

Wednesday, October 28, 2009

SVN discussion and summary

Our first meeting with Fardad about the OOP344 Assignment 2 was on Tuesday October 27, 2009 at 17:00. Our team experienced a few problems with SVN. A summary, and an edited transcription can be found at the following link...

http://zenit.senecac.on.ca/wiki/index.php/OOP344_Team_Funktion

Tuesday, October 20, 2009

c validate input/trailing characters

/* A simple program to demonstrate
* a way of validating input.
* By: Ljubomir Gorscak
* October 2009
*/

#include

int clear_input(void);
double validate(void);

main(){

double a;
double b;
double c;
int check = 0;

printf("give me price a: ");
a = validate();

printf("give me price b: ");
b = validate();

printf("give me price c: ");
c = validate();

printf("$%.2lf\n", a);
printf("$%.2lf\n", b);
printf("$%.2lf\n", c);
}

double validate(void){

double num;
int check;

do{

scanf("%lf", &num);
check = clear_input();

if (check > 0){
printf("Trailing characters are bad!\n");
printf("Please try again: ");
}

else if (num <= 0){
printf("Value must be greater than 0!\n");
printf("Please try again: ");
}
}while (check > 0 || num <= 0);

return num;
}


int clear_input(void){

int i = 0;

while (getchar() != '\n'){
i++;
}

return i;
}
/* end */

Wednesday, October 14, 2009

OOP344 assignment 1 - To compile on mac

This entire post can be copy/pasted into your ciol.h between
# if PLATFORM == PLT_LNX
and
# elif PLATFORM == PLT_BCC || PLATFORM == PLT_VCC



Notes are included in the commented-out area. Code starts here...

# elif PLATFORM == PLT_MAC
/*

To compile on mac:

Adding the line
#define NULL 0
fixed an error on mac that said
"NULL not defined"

be sure to #include inside ciol.c
eg.
# if PLATFORM == PLT_LNX
#include

# elif PLATFORM == PLT_MAC
#include

The message that I used to compile:
gcc as1tester.c ciol.c -lcurses

I got the following warnings when I compiled, but it still works.

ciol.c: In function ‘io_edit’:
ciol.c:185: warning: incompatible implicit declaration of built-in function ‘malloc’
ciol.c: In function ‘io_displayMenuItem’:
ciol.c:444: warning: passing argument 1 of ‘io_strlen’ discards qualifiers from pointer target type
ciol.c:445: warning: passing argument 1 of ‘io_strlen’ discards qualifiers from pointer target type
ciol.c: In function ‘io_menuItem’:
ciol.c:467: warning: assignment makes pointer from integer without a cast
ciol.c:470: warning: passing argument 6 of ‘io_displayMenuItem’ makes integer from pointer without a cast
ciol.c:475: warning: assignment makes pointer from integer without a cast
ciol.c:476: warning: passing argument 6 of ‘io_displayMenuItem’ makes integer from pointer without a cast

There are some strange looking characters in some of the strings
output by main. I will be investigating it.

The macbook pro does not have all the dedicated keys that
a full keyboard would have. I made a substitute key mapping
using modifier keys like [shift] and [option]. A chart, and
the key_codes are listed below.

Some useful PLT_MAC key combinations:
F1_KEY = [option] + [F1]
F2_KEY = [option] + [F2]
F3_KEY = [option] + [F3]
F4_KEY = [option] + [F4]
F5_KEY = [option] + [F5]
F6_KEY = [option] + [F6]
F7_KEY = [option] + [F7]
F8_KEY = [option] + [F8]
F9_KEY = [option] + [F9]
F10_KEY = [option] + [F10]
F11_KEY = [option] + [F11]
F12_KEY = [option] + [F12]
INSERT_KEY = [shift] + [option] + [I]
HOME_KEY = [shift] + [option] + [H]
END_KEY = [shift] + [option] + [E]
PGUP_KEY = [shift] + [option] + [U]
PGDN_KEY = [shift] + [option] + [D]
BS_KEY = [delete]
DEL_KEY = [fn] + [delete]
*/

#define UP_KEY 259
#define DOWN_KEY 258
#define LEFT_KEY 260
#define RIGHT_KEY 261
#define PGUP_KEY 168
#define PGDN_KEY 142
#define ENTER_KEY 10
#define TAB_KEY 9
#define BACKSPACE_KEY 127
#define DEL_KEY 330
#define HOME_KEY 147
#define END_KEY 180
#define ESCAPE_KEY 27
#define INSERT_KEY 134
#define F1_KEY 270
#define F2_KEY 271
#define F3_KEY 272
#define F4_KEY 273
#define F5_KEY 274
#define F6_KEY 275
#define F7_KEY 276
#define F8_KEY 277
#define F9_KEY 278
#define F10_KEY 279
#define F11_KEY 280
#define F12_KEY 281

Sunday, September 27, 2009

io_display in one line - not working yet :(

void io_display(const char *str, int row, int col, int len)
{

int i = 0;

len <= 0 ? io_move(row, col) && io_putstr(str) : io_move(row, col) && while(io_putch(str[i++])) && putch(' ');
}

Monday, September 21, 2009

OOP344 Challenge - Leaner and Meaner

/*
* GetInt.c
*
* Created by Ljubomir Gorscak
* 21/09/09.
* Seneca Learn Id : gljubomir
* OOP344 - Fall 2009
*
* Challenge: write this function without
* using any library functions;
* void GetInt(char *strint, int val);
* this function gets an integer value and
* converts it to a string ("strint")
*
* My lean and mean version has lots of
* notes but very little code. I include
* a main()and two additional functions
* for display.
*
* I changed the brackets so that the code
* will be easier to read on this blog.
*/

#include
#define MAX 6

void GetInt(char *, int);
void PrintStrint(const char *);
void PrintMAX();

int main()
{
int val;
char strint[MAX];

printf("Enter an integer less than ");
PrintMAX();
scanf("%d", &val);

printf("Your integer is: %d\n", val);

GetInt(strint, val);
strint[MAX] = '\0';

printf("The string version is: ");

PrintStrint(strint);

return 0;

} /* end of main */

/* this function gets an integer value
* and converts it to a string ("strint")
*/
void GetInt(char *strint, int val)
{
int i;
int mod_int;

mod_int = val % 10;
val /= 10;

for (i = MAX - 1; i >= 0; i--)
{
strint[i] = mod_int + 48;
mod_int = val % 10;
val /= 10;
}

} /* end of GetInt(...) */

/* this function is used to print the string
* version of the number without the leading
* zeros
*/
void PrintStrint(const char *strint)
{
int i = 0;

for ( ; i < MAX; i++)
{
if(i < MAX && strint[i] != '0')
for ( ; i < MAX && printf("%c", strint[i]); i++);
}

printf("\n");

} /* end of PrintStrint(...) */

/* this function is used to inform the user
* about the value of #define MAX so that
* the user does not exceed MAX input
*/
void PrintMAX()
{
int i = 0;

for ( ; i < MAX && printf("9"); i++);
printf(": ");

} /* end of PrintMAX() */


/*
* end
*/

Sunday, September 20, 2009

OOP344 Challenge - Answer

/*
* GetInt.c
*
* Created by Ljubomir Gorscak on 20/09/09.
* Seneca Learn Id : gljubomir
* OOP344 - Fall 2009
*
* Challenge: write this function without using
* any library functions;

* void GetInt(char *strint, int val);
* this function gets an integer value and
* converts it to a string ("strint")

*
*/

#include

void GetInt(char *, int);

int main(){

int val;
char strint[6];

printf("Enter an integer less than 999999: ");
scanf("%d", &val);

printf("Your integer is: %d\n", val);

GetInt(strint, val);
strint[6] = '\0';

printf("The string version is: %s\n", strint);

return 0;
}

/* this function gets an integer value
* and converts it to a string ("strint")
*/
void GetInt(char *strint, int val){

int mod_int = val % 10;
int temp_int = val / 10;
int i;

for (i = 6 - 1; i >= 0; i--){

strint[i] = mod_int + 48;
mod_int = temp_int % 10;
temp_int /= 10;
}
}


/*
* end
*/

Thursday, September 17, 2009

A shout out to my peeps in OOP344!

This is my first blog. Future blogs will probably have something to do with C/C++ programming.