Start off this is my first post so go easy on me :)

I am a beginner at C# programming and have been set the task of making a tamagotchi in a console application, my question is there anyone who can point me in the direction of a good tutorial or can supply some starter code or hints to get me going.

Thanks
:)

Hi narg, welcome here at daniweb:)
We don't know what your programming knowledge is at the moment, you have to tell us more. Have you already some code?
You obviously going to need the Timer class I guess and a lot of Console input and output. Look in Help menu (if you have VS C#??)to get more information about those classes to start with.

Thanks for the welcome =] and yea i have done a little programming before but I don't have a vast knowledge i have done a few other programs but only basic ones such as vending machine program in a console application and few other basic ones.

I have the brief of the program if you would like me to put that up here if that makes it easier?

Well narg...
the only thing you can do is, go through Google, and there you can find lots of good tutorial regarding this.........:)

dont worry im not expecting any help on the actual assignment to help this i wont upload the brief but i will sum it up... We have to basically create in console application using C# a tamagotchi which allows the user to feed, heal, play with it but the variable values for these are reduced as time goes on and it is stored in a external file.

Also regards to the google research ive had a look but i cant find any tutorials only pre made code to download which is cheating.

Read this info about a Timer class info about a Timer class
As input you will need some menu with options of what you want to do. Look and search around here, there must be some code you can use.

Many years ago I had to keep the tamagotchi of my daughter, she could not keep him, she had to go to school. I took it to work and forgot about it, until in the mid of that important meeting ...:icon_mrgreen:

You say you will be storing the values in an external file, does this mean you want to be able to close the application but still track changes over time when the application is restarted..eg, hunger is at 0% when app closes, 5 hours later app starts, hunger is now at 50%.
If so, a timer will only help you while the app is open. You will need to log the time of the last feed in the file along with the resulting hunger value. Then when the app is started, retrieve the values and calculate any change based on the timespan that has passed since the last feed, eg:

TimeSpan hunger = DateTime.Now - lastFeed;

Obviously open to cheating by changing system clock, but its a start ;)

You say you will be storing the values in an external file, does this mean you want to be able to close the application but still track changes over time when the application is restarted..eg, hunger is at 0% when app closes, 5 hours later app starts, hunger is now at 50%.

TimeSpan hunger = DateTime.Now - lastFeed;

yea it does and thanks very much :D this is gonna take me a while to do i think as i dont have a very good knowledge yet but with the tips and help it should speed things up :D cheers

Just a quick update the tamagotchi is going well but i can't get my head round how to write it to a file and then open it from that file keeping where the tamagotchi state was instead of reopening and starting the program all over again.

any tips or help on this?

I don't know how you save your tamagotchi status to a file. I think I would save all the info in a struct and write that to a file. If the tamagotchi comes awake or is started up again, I would read the last struct, to get the most recent info.

Edited 7 Years Ago by ddanbe: n/a

If you store all the details of the tamagotchi in a class (good encapsulation) then you can implement ISerialisable on the class and write a serialiser that will write the entire class to a file.
Theres a really well written tutorial here. I used it when i was getting my head around serializers.
If thats a bit too advanced for you, you could just build a Comma Seperated Values file; put each value you want to store together in a string like:
Name = "Tam"
Created = 12:00 01/01/2010
Hunger = 50
Happiness = 89

string Data = "Tam,12:00 01/01/2010,50,89". Then you write that string to a file. When you read it back in you can use string[] data = fileString.Split(","); to seperate the values.

Hey guys i have almost sorted out this tamagotchi i just dont know how to save the state to a text file so i can reopen it from that instead of starting a new game everytime, any help?

see my last post for options to save status, then when you load your app have it read in the status and set tamagotchi back to how it was at last exit.

ive done it thanks :D this thread has been alot of help thankyou so much guys!

no problem :) Which method did you use to save the status in the end?
If you didnt use a serialiser, i'd recommend reading up on them for future reference. They allow you to store the entire state of an object in binary or xml format.
If you need to save the state of an app between closing and opening, or transmit a class (variable state included) across a network, etc, this is much mroe versatile than using text files :)

For a job this simple a text file is fine...of course, a binary file would make it a lot harder for the the user to go in and change the state of their tamagotchi.

remember to mark the thread as sovled

Edited 7 Years Ago by Geekitygeek: n/a

Just marked it as solved now cheers for the reminder :) and i for this i used a text file to save it as that seemed simple and did what i needed to do =] ill defiantly read up more on that type of save though =]

Start off this is my first post so go easy on me :)

I am a beginner at C# programming and have been set the task of making a tamagotchi in a console application, my question is there anyone who can point me in the direction of a good tutorial or can supply some starter code or hints to get me going.

Thanks
:)

Martin is on to you, I think you have already faild by asking the code for tamagotchi!!!!

This question has already been answered. Start a new discussion instead.