Register
Login 




New Topic Post Reply  [ 25 posts ]  Go to page
1, 2, 3
 >> Next 
  Print view
Previous topic | Next topic 
Author Message
Offline 
 Post subject: Small but learning...
PostPosted: Tue Jan 10, 2017 11:52 am 
User avatar
Staff
Legend
Steam ID: STEAM_0:1:221617357
Joined: Thu May 19, 2016 9:30 am
Posts: 2168
Location: United Kingdom
hey i wanted to share what I've been doing in college today!

This is my second year in Level 3 IT and it's going pretty well.


At the minute in Programming, we are currently doing Object Oriented Programming, yeah.

We have been practicing nd stuff on Windows Form Applications and have been producing some small things.


Last year we were doing Procedural Programming, we were using Console Applications for that.


Today we did some excersises and had to do one task on our own, which was create 3 buttons using code (without using tool box to draw it) using the Button code and assigning a variable which is basically the name of the button, example:

Button EgNForums; <- This just means when the variable EgNForums is used, it refers to a button as I believe.
public Form1();

to create a button with the name EgNForums, all you have to do is:

EgNForums = new Button();

Baring in mind this is very easy stuff.

here is the full project:

Code:
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace WindowsFormsApplication9

{

      public partial class Form1 : Form

     {

                Button noLady;

                Button Lady;

                Button noLady1;

      public Form1()

      {

                InitializeComponent();

                noLady = new Button();

                Controls.Add(noLady);

                noLady.Text = "Find the Lady";

                noLady.Left = 70;

                noLady.Top = 50;

                noLady.Width = 100;

                noLady.Height = 40;

                noLady.Click +=new EventHandler(noLadyAction);

                Lady = new Button();

                Controls.Add(Lady);

                Lady.Text = "Find the Lady";

                Lady.Left = 120;

                Lady.Top = 100;

                Lady.Width = 100;

                Lady.Height = 40;

                Lady.Click +=new EventHandler(LadyAction);

                noLady1 = new Button();

                Controls.Add(noLady1);

                noLady1.Text = "Find the Lady";

                noLady1.Left = 200;

                noLady1.Top = 350;

                noLady1.Width = 100;

                noLady1.Height = 40;

                noLady1.Click +=new EventHandler(noLady1Action);

      }

      private void noLadyAction(object sender, EventArgs e)

      {

                MessageBox.Show("This is not the lady, please try again");

      }

      private void LadyAction(object sender, EventArgs e)

      {

               MessageBox.Show("You found the Lady, well done");

      }

      private void noLady1Action(object sender, EventArgs e)

      {

               MessageBox.Show("This is not the lady. please try again");

      }

  }

}




The problem is, when you click one of the buttons and it displays you found the lady, it doesnt randomize, it is the same button each time and I want to work on randomizing it making it change buttons each time it is debugged or ran.

By the way this is using C#, I use Visual Studio.

NO HARSH COMMENTS OK!
BRITNEY SPEARS killed <>< with knife.

Image

Spoiler: Show


Spoiler: Show

Spoiler: Show


1. Join EgN [ X ]
2. Become a Recruit [ X ]
3. Become an EgN Member [ X ]
4. Become a Admin [ X ]
5. Become an Elite [ X ]
6. Become a Veteran [ X ]
7. Become a part of Events Team [ X ]
8. Become a Manager [ ]
9. Become a Staff [ X ]
10. Become an Advisor [ ]
11. Become the next EgN Leader! [ ]

EgN| Mr Geeza™ : Why do I always get you and sinister mixed up lol sorry xD
EgN-S| Phillip: Cause you a racist

Jafari asks the wall: What is the meaning of life?
The wall responds with: Kill yourself. DUN DUN DUUUUUUUUUUN
EgN-S| Mr.GoldGames: I asked for a demotion, where's my demotion at?
1 month later....
The following people have been recognised for their service to the community:

Veteran to Staff
Mr.GoldGames

EgN-S| Mr.GoldGames: I ask for a demotion but I got a promotion instead? Life sucks sometimes.


Last edited by Geeza on Wed Jan 11, 2017 8:30 am, edited 1 time in total.

Top
 Profile  
 Social 
Offline 
PostPosted: Tue Jan 10, 2017 12:08 pm 
User avatar
EgN Member
Elder
Steam ID: STEAM_0:1:22040504
Joined: Mon Jan 04, 2016 12:13 am
Posts: 1404
Location: Philadelphia, PA
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication9 {

public partial class Form1 : Form {

   Button noLady;
   Button Lady;
   Button noLady1;

   public Form1() {
         InitializeComponent();

         noLady = new Button();
         Controls.Add(noLady);

         noLady.Text = "Find the Lady";
         noLady.Left = 70;
         noLady.Top = 50;
         noLady.Width = 100;
         noLady.Height = 40;

         noLady.Click +=new EventHandler(noLadyAction);

         Lady = new Button();
         Controls.Add(Lady);

         Lady.Text = "Find the Lady";
         Lady.Left = 120;
         Lady.Top = 100;
         Lady.Width = 100;
         Lady.Height = 40;
         Lady.Click +=new EventHandler(LadyAction);

         noLady1 = new Button();
         Controls.Add(noLady1);

         noLady1.Text = "Find the Lady";
         noLady1.Left = 200;
         noLady1.Top = 350;
         noLady1.Width = 100;
         noLady1.Height = 40;
         noLady1.Click +=new EventHandler(noLady1Action);

      }

      private void noLadyAction(object sender, EventArgs e) {         
         MessageBox.Show(generateRandomText());
      }

      private void LadyAction(object sender, EventArgs e) {
         MessageBox.Show(generateRandomText());
      }

      private void noLady1Action(object sender, EventArgs e) {
         MessageBox.Show(generateRandomText());
      }
      
      private string generateRandomText() {
         int randomNumber = new Random().Next(1, 3);
         
         switch (randomNumber() {
            case 1:
               return "Random lady one";
               break;
               case 2:
               return "Random lady two";
               break;
               case 3:
               return "Random lady three";
               break;
               default:
               return "Random lady default";
               break;
         }      
      }
   }

}

gg no re
Gonna revise your Levi's with physical harm
Put divets in the rivets with my physical arm
Gonna beat those jeans, gonna dip em in slime
Turn your 501s into 499s

The Senate: Did you ever hear the tragedy of Darth Plagueis The Wise?
Anakin: No
The Senate: I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side, he could even keep the ones he cared about from dying.
Anakin: He could actually save people from death?
The Senate: The dark side of the Force is a pathway to many abilities some consider to be unnatural.
Anakin: What happened to him?
The Senate: He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.
Anakin: Is it possible to learn this power?
The Senate: Not from a Jedi.


Last edited by CharlieKelly on Tue Jan 10, 2017 1:19 pm, edited 1 time in total.

Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:09 pm 
User avatar
Staff
Legend
Steam ID: STEAM_0:1:43792252
Joined: Wed Nov 11, 2015 4:07 pm
Posts: 2713
From the looks of it and by what you're saying,

Last year you did some small C++ console apps (could've been C# too)

and now you're learning .NET Visual Studio with C#

I'm not sure if it's just how you pasted it in your [code] tag, but the formatting isn't all that great

Indentation and commenting your code is key to becoming a better developer. Especially when you want others to critique your work. If you ever need help I can show you some pointers but I (and I hope nobody else) will be doing your homework for you

edit: gg charlie
-No Pity For A Coward-
http://cdn.funnyisms.com/ecc914b3-1ce2-4aa7-8b36-992cf563121f.jpg
"im srry, i din mean it massta, lil simple is gone be a good boy massta" -Mr. Simplistic
"Your taste in music is A2+ and I like how you moto." -Needy

Image


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:11 pm 
User avatar
EgN Member
Elder
Steam ID: STEAM_0:1:22040504
Joined: Mon Jan 04, 2016 12:13 am
Posts: 1404
Location: Philadelphia, PA
Yiggles Moto wrote:
From the looks of it and by what you're saying,

Last year you did some small C++ console apps (could've been C# too)

and now you're learning .NET Visual Studio with C#

I'm not sure if it's just how you pasted it in your [code] tag, but the formatting isn't all that great

Indentation and commenting your code is key to becoming a better developer. Especially when you want others to critique your work. If you ever need help I can show you some pointers but I (and I hope nobody else) will be doing your homework for you

edit: gg charlie

Yea, Im just that bored at work.
Gonna revise your Levi's with physical harm
Put divets in the rivets with my physical arm
Gonna beat those jeans, gonna dip em in slime
Turn your 501s into 499s

The Senate: Did you ever hear the tragedy of Darth Plagueis The Wise?
Anakin: No
The Senate: I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side, he could even keep the ones he cared about from dying.
Anakin: He could actually save people from death?
The Senate: The dark side of the Force is a pathway to many abilities some consider to be unnatural.
Anakin: What happened to him?
The Senate: He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.
Anakin: Is it possible to learn this power?
The Senate: Not from a Jedi.


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:12 pm 
User avatar
Staff
Legend
Steam ID: STEAM_0:1:43792252
Joined: Wed Nov 11, 2015 4:07 pm
Posts: 2713
@Geeza, take a look at Charlie's code. I hope that's how you have yours indented, etc in your actual code...

@Charlie, gg no re
-No Pity For A Coward-
http://cdn.funnyisms.com/ecc914b3-1ce2-4aa7-8b36-992cf563121f.jpg
"im srry, i din mean it massta, lil simple is gone be a good boy massta" -Mr. Simplistic
"Your taste in music is A2+ and I like how you moto." -Needy

Image


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:13 pm 
User avatar
EgN Member
Elder
Steam ID: STEAM_0:1:22040504
Joined: Mon Jan 04, 2016 12:13 am
Posts: 1404
Location: Philadelphia, PA
Yiggles Moto wrote:
, take a look at Charlie's code. I hope that's how you have yours indented, etc in your actual code...

, gg no re


Ya I was gonna quickly show the new function, but I just couldn't handle the crappy formatting, it was killing me inside.

also () {
}

>

()
{
}

ILL FITE YA IF YOU DISAGREE
Gonna revise your Levi's with physical harm
Put divets in the rivets with my physical arm
Gonna beat those jeans, gonna dip em in slime
Turn your 501s into 499s

The Senate: Did you ever hear the tragedy of Darth Plagueis The Wise?
Anakin: No
The Senate: I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side, he could even keep the ones he cared about from dying.
Anakin: He could actually save people from death?
The Senate: The dark side of the Force is a pathway to many abilities some consider to be unnatural.
Anakin: What happened to him?
The Senate: He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.
Anakin: Is it possible to learn this power?
The Senate: Not from a Jedi.


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:15 pm 
User avatar
Staff
Legend
Steam ID: STEAM_0:1:43792252
Joined: Wed Nov 11, 2015 4:07 pm
Posts: 2713
CharlieKelly wrote:
Yiggles Moto wrote:
, take a look at Charlie's code. I hope that's how you have yours indented, etc in your actual code...

, gg no re


Ya I was gonna quickly show the new function, but I just couldn't handle the crappy formatting, it was killing me inside.

also () {
}

>

()
{
}

ILL FITE YA IF YOU DISAGREE


I have never used
Code:
function()
{
    //code
}


It just kills me to even look at it
-No Pity For A Coward-
http://cdn.funnyisms.com/ecc914b3-1ce2-4aa7-8b36-992cf563121f.jpg
"im srry, i din mean it massta, lil simple is gone be a good boy massta" -Mr. Simplistic
"Your taste in music is A2+ and I like how you moto." -Needy

Image


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:16 pm 
EgN Member
Steam ID: STEAM_0:0:61594940
Joined: Tue Nov 12, 2013 5:35 pm
Posts: 3554
Charlies is way neat :)
https://www.redditgifts.com/?inv=CMv5 Join reddit gifts and get free items but you do have to send back gifts or you'll get penalized
After reading every EgN Post
Image

Image

Image

Image

Image

Image


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:19 pm 
User avatar
EgN Member
Elder
Steam ID: STEAM_0:1:22040504
Joined: Mon Jan 04, 2016 12:13 am
Posts: 1404
Location: Philadelphia, PA
YigglesMoto wrote:

I have never used
Code:
function()
{
    //code
}


It just kills me to even look at it

Yea I always like the first version... but looking at my codebase I've been using that way almost exclusively lmao, didn't even notice.
I think it just auto-formats like that in Visual Studio and I've been too lazy to change it.

Fuck it, as long as its consistent idgaf.
Gonna revise your Levi's with physical harm
Put divets in the rivets with my physical arm
Gonna beat those jeans, gonna dip em in slime
Turn your 501s into 499s

The Senate: Did you ever hear the tragedy of Darth Plagueis The Wise?
Anakin: No
The Senate: I thought not. It’s not a story the Jedi would tell you. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side, he could even keep the ones he cared about from dying.
Anakin: He could actually save people from death?
The Senate: The dark side of the Force is a pathway to many abilities some consider to be unnatural.
Anakin: What happened to him?
The Senate: He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.
Anakin: Is it possible to learn this power?
The Senate: Not from a Jedi.


Top
 Profile  
  
Offline 
PostPosted: Tue Jan 10, 2017 12:21 pm 
User avatar
Staff
Legend
Steam ID: STEAM_0:1:43792252
Joined: Wed Nov 11, 2015 4:07 pm
Posts: 2713
CharlieKelly wrote:
YigglesMoto wrote:

I have never used
Code:
function()
{
    //code
}


It just kills me to even look at it

Yea I always like the first version... but looking at my codebase I've been using that way almost exclusively lmao, didn't even notice.
I think it just auto-formats like that in Visual Studio and I've been too lazy to change it.

Fuck it, as long as its consistent idgaf.


Like this?
Image
-No Pity For A Coward-
http://cdn.funnyisms.com/ecc914b3-1ce2-4aa7-8b36-992cf563121f.jpg
"im srry, i din mean it massta, lil simple is gone be a good boy massta" -Mr. Simplistic
"Your taste in music is A2+ and I like how you moto." -Needy

Image


Top
 Profile  
  
Display posts from previous:  Sort by  
New Topic Post Reply  [ 25 posts ]  Go to page
1, 2, 3
 >> Next 


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  

cron
Powered by phpBB3 ©
Website mods by Doldol, banner by synthic, Mootiny.