Showing posts with label ST I - (105). Show all posts
Showing posts with label ST I - (105). Show all posts

Saturday, July 2, 2011

Stacks and Queues GUI applications

These are some GUI applications I developed when I was following the 'Software Technology I' subject when I was in the second semester of the first year at SLIIT. I think this will be useful to learn not only Stacks and Queues but also tasks like exception handling when implementing a C++ GUI application in Visual Studio.

This Stack application demonstrates the fundamental tasks of a Stacks such as Push, Pop and Peek methods.




Click Here to download the application. (19.84 KB)
Click Here to download the Visual Studio project source code. (2.4 MB)


The Queue application demonstrates the tasks related to Queues such as Enqueue, Dequeue and Peek Front.

Click Here to download the application. (20.09 KB)
Click Here to download the Visual Studio project source code. (3.11 MB)

You need to have .NET Framework 3.5 installed in your PC to run these applications.


-Tharindu Edirisinghe-
-SLIIT 10'-

Sunday, January 23, 2011

C++ again and Dynamic 2D Arrays

I hope you remember my friend at the University of Sri Jayawardenapura. This time also he needed my help to do a programming assignment.

Before coming to the question, I'll tell you what I learned by doing the assignment.

Do you know how to create an array Dynamically ? Lets say you want the user to enter a size and according to that size, you create an array of the given size dynamically.

int size;
cout<<"Enter the size of the array : ";
cin>>size;
int *myarray = new int[size];

The above code is correct. But have you ever tried to create a 2D array dynamically. I wanted to create a 2D array of a given number of rows and 2 columns. I tried it this way.

int rows;
cout<<"Enter the rows you want : ";
cin>>rows;
int *myarray = new int[rows][2];

When I compiled the program, I got errors and I realized that the above method is incorrect. So I went through some C++ forums and finally found the solution. This is one of the correct ways to create a 2D array dynamically.

int (*myarray)[2] = new int[rows][2];

The the value for the variable 'rows' can be given either from a key board input or from assigning a value from some other variable (eg: using a count variable).

I hope now you know it. This is the problem I had to solve.

Question

Applicants who obtain over 75 marks for the test will be called for the first interview.
Applicants who obtain over 50 marks for the first interview will be called for the second interview.
Each selected applicant has to face the second interview.
First six applicants who obtain highest marks for the second interview will be selected for the management trainee position.

The bank has received 500 applications for the selection test and applicants have been numbered from 1 to 500.

Write a C++ program to do the following tasks:

->To define a one-dimensional array to store the marks obtained by each applicant for selection test.
->To input marks obtained by each candidate for the test.
->To define another one-dimensional array to store the applicant's number for those who have been selected for hte first interview.
->To display the applicant's number of those who have been selected for the first interview.
->To define a two-dimensional array to store the applicant's number and marks obtained by each applicant selected for the second interview.
->To input applicant's number and marks obtained by each applicant for the second interview.
->To display the numbers of those who have been selected for the management trainee position.

I drew a plan to understand the question.

Since I cannot check it for 500 marks, I gave 20 for the number of applicants.
Once the user inputs the marks of all the candidates, the program should select the candidates having more than 75 marks and should display their registration number. They are the candidates who have been selected for the 1st interview.

Then the user has to enter the marks obtained by the candidates from the 1st interview. The program should allow only to enter marks for those who have got more than 50 marks among the selected candidates for the 1st interview. The above image shows that. 

Once the user has input all the marks of the selected candidates for the 2nd interview, again needs to enter the marks obtained from the 2nd interview among those who got more than 50 marks from the 1st interview. Now the program should allow only to enter marks for those who have passed the test and also the 1st interview.
Then finally it should select the top six candidates based on their marks from the 2nd interview and display them.

Click Here to download the source code (106.99 KB).

P.S - This is the longest program I wrote in C++ without using any functions other than the main().

-Tharindu Edirisinghe-
-SLIIT 10'-

Sunday, January 16, 2011

Software Technology 1 assignment at SLIIT - (Part 4, Final)

If you couldn't read the Part I, Part II and Part III of this series, first read them.

Finally we had to do a presentation to demonstrate the application we had developed. I went to SLIIT around 9.00 A.M although we had to deliver the presentation at 3.00 P.M. Asitha, Dimantha and Mezaj also came and since they didn't have any idea about what Sasika and I had developed, I showed them how to use the application and described the functions and the coding because they should know everything when we deliver the presentation. 

While they were going through the application and the coding, I helped some other groups who had problems with their applications. After sometime, Sasika also came. That was the first time all five group members got together to do something regarding the project. Sasika brought the latest version of the application with no bugs and he had also designed a graphic using photoshop to appear first when the application loads. We didn't know how to add a progress bar to that, but we found the code from a Youtube video. We added it to our application. 
The above image shows the loading window of our application. It was a unique feature among all of the applications which other groups had developed. 

(Team SS was the name we selected for our group. It was because we used to call Sasika as SS and I suggested to select that name for our group in order to pay gratitude to Sasika for his tremendous help with developing the application)

Here you see some of the screen shots of our application.





At 3.00 P.M, we went to 12 Lab 2 to deliver our presentation. When compared to the applications of the other groups had developed, our one was the best in graphics, user friendliness and from functionality. We did a good presentation there. 

This photo was taken after we did the presentation. (From left to right, Sasika and myself).
This is our group - TEAM SS.
(From left to right, myself, Sasika, Mesaj, Asitha and Dimantha)

Finally, I'm proud to be their leader !

Click here to download the application we finally developed (1.25 MB)
Click here to download the source code (11.56 MB).

P.S - The marks we got for the presentation was not added to the final results of the Software Technology I subject. But it was a great opportunity to work on such a project and the experience I got will never be forgotten. Besides that, there was a complete question in the final exam paper which was related to the assignment we did. In a way, the assignment helped me to get an 'A' from the final exam.


-Tharindu Edirisinghe-
-SLIIT 10'-

Saturday, January 15, 2011

Software Technology 1 assignment at SLIIT - (Part 3, Output)

If you haven't read the  part 1 and part 2 of this post, read them first.

I kept on working on developing the application according to the given specifications and finally developed a complete application four days before the deadline. I had only used one windows form but it contained all the functions required.
The above image shows the application which I developed. 

Click Here to download the application (207.65 KB). 
Click Here to download the source code (4.11 MB). 

As I told you previously, I didn't find new methods when implementing the application. For example, in the stocks update function, the user had to input the current date as an integer because I didn't use the calendar feature which comes with Microsoft Visual Studio. If the current day is 2011- 01-15, the user must enter it as 20110115.  

By that time, Sasika had resigned from his job and I asked me to meet him at SLIIT. I took the source codes with me and he also brought the application which he had further developed from the source code which I gave him previously. 

He had found the code to use the same linked list from all the windows forms and he showed me how it works. That time I realized the importance of having group members who are eager to find new things. I had no intension of working on the project again as I worked hard even without having a proper sleep. So I gave the source code of the final application and described every single line in the code to him.

Two days left without receiving any message from Sasika. I also was not bothered to call him because I decided to submit the application which I developed if Sasika failed to develop it further. Then finally I received a call from him around 2.00 A.M, one day before the deadline. He told that the project was a success and he wanted a further clarification on the function which I implemented to update the stocks of the pharmacy. I gave him the information he needed and he asked me to meet him at SLIIT around 9.00 A.M. 

I went to SLIIT on time and he was not there. I understood his plight and waited until he came. He had slept around 5.00 A.M so that he came to SLIIT around 11.30 A.M.   He showed me the further developed application and I was amazed by seeing it.

As he was good in graphic designing, he had designed images for the buttons and the background. He had also put shortcuts in the application to make a better user friendly environment. 

He had implemented a function to get the system date so that the user doesn't need to enter the current date manually when updating stocks. But the function he had implemented was not supporting the function which I wrote to update stocks. So we both worked on correcting that function. At that time we couldn't find free space to work as there were so many students in the common rooms of every floor. 

 Finally a dustbin came to help us :D.........
The below image shows me, working on correcting some errors.
This is Sasika. 
We couldn't finish the work there as we were chased away by the cleaning staff of SLIIT. So we went home and I gave instructions to Sasika over the phone. 

Next day we had to submit the project before 5.00 P.M. We got together at SLIIT and kept on working. Although we had lectures to attend, we didn't go to them as the project was so important. Other thing was some other groups also sought help from us and while helping others, we worked on our project also. We were asked to upload the source code to the course web but the maximum file size was 2 MB. Our application had a larger size than that and so that we were asked to write the files to a CD and submit it to the 16th Floor. 

Around 4.50 P.M, we could finish all the work. Sasika didn't have a CD burning software in his laptop. Fortunately I had the setup of NERO in my laptop although I didn't have it installed. I installed it quickly and wrote the files to the CD. Since my laptop was very slow, We exceeded the deadline. Around 5.10 P.M we completed that and submitted it. Unfortunately our project was marked under the 'late submissions'. 

To be continued......
-Tharindu Edirisinghe-
-SLIIT 10'-

Wednesday, January 12, 2011

Software Technology 1 assignment at SLIIT - (Part 2, Preparation)

From my previous post I described about forming the group. From this post, I'll tell you what happened after that.

Although we were given two weeks to develop the application, we were busy with our studies and other work. Since we all were doing the week end course we had problems with finding time to discuss the solution we should develop. We did the week end course not because we wanted, but because we had no other option. Sasika was working at Citizens Development Bank and Mezaj was following a course at APIIT. I also was following some other academic course on week days. Only Asitha and Dimantha were free on week days. 

On Saturdays and Sundays, we had no free time even to discuss the project as we had continuous lectures, practicals and tutorials. Even on week days, we were unable to find a convenient time. It wasn't fair to ask Sasika to come to SLIIT on a week day as he had to work until 5.30 P.M at the bank. Mezaj was also having lectures at APIIT most of the time on week days. One option we had was to give Asitha and Dimantha all the work and help them to develop the application. It was impossible as they were not good in programming. So as the leader of the group, I had no option other than postponing the project. 

However Asitha and Dimantha were asking me always what they could do to contribute to the project. I kept on saying, "Don't worry guys, we'll do it before the deadline". It was because I had a plan in my mind of how to develop the application. 



Day by day we were reaching the deadline and finally we had only one week. I couldn't just wait without doing anything and so that I thought of developing the application alone. According to the requirements of the application, I thought it was best to use a linked list. 

First I drew a plan and defined the classes comparing to the real world scenario. It took two nights to develop the plan with attributes and the basic functions it should contain. Then I implemented some basic functions and created a simple GUI application. It was working perfectly, proving that my plan was perfect. I had used only one windows form and I thought that it would be best if I could more forms in the same application. To do that, I should use the same linked list for the whole application and I understood that I should be able to access the linked list from all of the forms. 

Unfortunately I didn't know how to do that and tried to find some help online. I visited so many websites and forums but couldn't find a method to apply to the solution. I took the application to a ST II lab session and ask the lecturer how to do that. Ms. Anjalie Gamage was our ST lecturer and she showed me an example of how to call a windows form using another windows form. Sasika was with me in the lab class and I showed him the application I developed and I described the logic in that. He took a copy of the source code saying that he would try to develop it further. 

I kept on working on the project alone and I realized that I could finish the whole project by myself without seeking the help of others. I thought that it would be better not to waste time on finding new methods as I was running out of time and decided to further develop the application with the programming knowledge I had. 

To be continued......

Read the part 3 of this post.

-Tharindu Edirisinghe-
-SLIIT 10'

Software Technology 1 assignment at SLIIT - (Part 1, Selecting Groups)

When we were at the 2nd semester of the 1st year, we had to develop an application for a pharmacy as an assignment in the ST I subject. It was a group assignment (5 members per team). From this post, I'd like to recall the memories of doing the assignment.



First thing is how I selected a group. From the post 'TC Presentation' I mentioned how I was chosen as the leader of that group. By the time the assignment was given, I had so many experiences of becoming a leader. For the 'TC Presentation' I was the leader of the group. Then for the DBMS I and ITA projects also, I was the group leader. 

From my previous post 'week end course at SLIIT' I told you that I was doing the week end course for the 2nd semester of the 1st year and also I discussed some of the problems we had. So when selecting the group I had to consider so many things. But you know, most of the students doing the week end course, either do a job on week days or follow some other academic course. So the probability of coming to SLIIT on week days to do an assignment is very low. I knew that, but the options left were limited. 

I was fed up with leading the DBMS and ITA group projects then and so that I wanted a brand new start for ST I project. I had the confidence of doing a good project and I always knew that I could rely on Sasika (SS) so I selected him.

I had three main reasons to select him.
  1. He got 30/30 for ST II subject from the mid exam where I got only 28/30.
  2. He was good in graphic designing.
  3. He was a person who never gives up.
Then Mesaj was in my DBMS and ITA groups and he was good in doing presentations. So I selected him also. Then we needed two members more.

I had two friends called Asitha and Dimantha and they asked me to take them to my group. I must tell something about them also. They joined the week end course sometime after the semester began and so that they were unable to join a group for DBMS and ITA projects. So Asitha and Dimantha were doing those projects with having only themselves in their group. So I took them into my group. Then our team was complete. In previous group assignments, other members elected me as the leader. But in ST project, I elected myself as the leader and recruited members to my group. 

The task was to develop an application for a pharmacy. The application should be able to insert, delete, modify data, check expiry date of medicine, update stocks, generate stock balance reports, generate reorder level reports and so on. We had to use C++ as the programming language.

From my next post, I'll tell you what happened then. 

Click Here to download the assignment specification (76.52 KB).

Read the next post of this series.

-Tharindu Edirisinghe-
-SLIIT 10'-