8 Replies - 1148 Views - Last Post: 09 June 2014 - 05:25 PM Rate Topic: -----

#1 bunny03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-June 14

Console Application to an application with graphic

Posted 09 June 2014 - 04:45 AM

Hi guys, it's my first post!!!!Applause, applause!

Recently, i create a mystery number game for console, but i want to add graphic in it and i can't do that with a console.
My question is How can i switch for an application with graphic? and don't say windows form i prefer real coding ;)
The code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Openclassroom_Mes_test
{
    class Program
    {
        static void Main(string[] args)
        {
            int choix = 1;
            while(choix == 1)
            {
                int trying = 0;
                int playernumber = 1;
            int mysterynumber = new Random().Next(0, 100);
            Console.WriteLine("Mystery number game");
            while (playernumber != mysterynumber)
            {
                
                Console.WriteLine("Entrez le chiffre que vous pensez(entre 0 - 100):");

                string saisie = Console.ReadLine();
                if (int.TryParse(saisie, out playernumber))
                {
                    if (playernumber < mysterynumber)
                    {
                        Console.WriteLine("High!\n");
                        trying++;
                    }
                    else if (playernumber > mysterynumber)
                    {
                        Console.WriteLine("low!\n");
                        trying++;
                    }
                    else
                    {
                        Console.WriteLine("Congrat!\n");
                        trying++;
                        Console.WriteLine("You win with " + trying + " trying");
                    }

                }
                else
                {
                    Console.WriteLine("Incorrect number");
                }
                }
            Console.WriteLine("New game?1 Yes/Other No");
            string choix2 = Console.ReadLine();
            if (int.TryParse(choix2, out choix))
            {
                if (choix == 1)
                {
                    Console.WriteLine("Again!");
                }
                else
                {
                    Console.WriteLine("This is the end...");
                }
            }
            

            }









        }
            
        }
    }







Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Console Application to an application with graphic

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: Console Application to an application with graphic

Posted 09 June 2014 - 04:51 AM

Erm, well Windows Forms does allow you to add graphics...

Quote

i prefer real coding


What?

Are we talking about just simple graphics or high end like games? For games you want to look into DirectX or OpenGL (but be prepared for a steep learning curve). For simple graphics on a window use WPF, not the outdated WinForms.

What kind of graphics do you want?
Was This Post Helpful? 1
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,379
  • Joined: 02-June 10

Re: Console Application to an application with graphic

Posted 09 June 2014 - 05:49 AM

View Postbunny03, on 09 June 2014 - 05:45 AM, said:

and don't say windows form i prefer real coding ;)/>/>


Nothing like insulting a couple hundred thousand developers that have earned a living as software engineers in WinForms over the last couple decades, to make them want to help you. If you think WinForms means nothing but drag-n-drop from the toolbox then you are merely showing your ignorance. You might want to clarify what you mean by "real coding".

By the way - WinForms is legacy UI technology. Might as well be VB6. In today's market new projects are built on WPF. If you can't code for WPF there's little point applying for the job these days.

C# Learning Series, right here on DIC

Build a WPF window with style

See also the WPF for WinForms developers links in my signature block

This post has been edited by tlhIn`toq: 09 June 2014 - 04:00 PM

Was This Post Helpful? 1
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,379
  • Joined: 02-June 10

Re: Console Application to an application with graphic

Posted 09 June 2014 - 05:55 AM

Before getting on your high horse about WinForms not being "real programming" you might want to work on learning the basics. Your use of random won't really get much in the way of real randomness. As long as you keep making a new random object every time you increment through your loop. You need to make one random at class-level scope then keep getting a new .Next from it.

Also, you aren't doing any validation of the user input. You can't assume they will always give you a number. What happens if the user types "five" instead of "5"?
Was This Post Helpful? 1
  • +
  • -

#5 bunny03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-June 14

Re: Console Application to an application with graphic

Posted 09 June 2014 - 01:16 PM

Thanks for reply and with "i prefer real coding" it's my ignorance sorry. There's any WPF Tutorials?

Thanks and sorry again ;)
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,379
  • Joined: 02-June 10

Re: Console Application to an application with graphic

Posted 09 June 2014 - 04:01 PM

View Postbunny03, on 09 June 2014 - 02:16 PM, said:

There's any WPF Tutorials?


Do you mean like the ones we already linked to you in post #3 above?
Dude, read the responses! You're asking for stuff we've already given you just 2 posts back.
Was This Post Helpful? 0
  • +
  • -

#7 bunny03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-June 14

Re: Console Application to an application with graphic

Posted 09 June 2014 - 04:50 PM

You just edit the link... When a link is not linked i can't use it of curse.
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,379
  • Joined: 02-June 10

Re: Console Application to an application with graphic

Posted 09 June 2014 - 05:23 PM

I fixed one link. The other 3 were always there. The one for the C# learning series is a table of contents referencing back to the the others. So effectively the link I fixed was redundant, but convenient.

I'm going to unsubscribe to this thread now. Best of luck in your project.
Was This Post Helpful? 1
  • +
  • -

#9 bunny03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-June 14

Re: Console Application to an application with graphic

Posted 09 June 2014 - 05:25 PM

Thanks for help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1