College project
I have this project that's due in quite soon but ANY help is greatly appreciated considering i'm not too sure where to start. I have a file with all the cards on so that bit is done for me but the rest is a bit challenging for me.
158 Replies
if you need GUI, then Windows Forms Application .. If not, make a simple console application
As simple as that
So just to clarify, you have not even started so far?
That looks like a console application should be fine, IMO
I concur, starting with a console application would be good
yep, it should be pretty simple to implement it as a console application, I can help you if you want, but I would need the code provided to you by your teacher to give u a small beta and show you how I started
to be fair it sounds like a project which takes 1-2 hours if it is an console application
I started it but not finished, it's due in on monday but i doubt he'll even check
c# or which language
i scrapped the code he gave me and started it by myself, i can show you what ive done so far
yes, C#
thats fine, I always do that xD
nice
should i send a screen shot or copy and paste
would be great, but dont need to, I just need the data for the dog cards
How you think its best
alright be back in a sec then
np
okay so these are the dog cards (dogsdata.txt):
Annie the Afgan Hound,1,4,7,9
Bertie the Boxer,6,7,7,10
Betty the Borzoi,5,4,10,9
Charlie the Chihuahua,7,9,7,10
Chaz the Cocker Spaniel,9,8,2,1
Donald the Dalmatian,10,2,6,3
Dottie the Doberman,8,9,6,3
Fern the Fox Terrier,3,1,8,6
Frank the French Bulldog,4,7,8,6
George the Great Dane,3,3,7,4
Gertie the Greyhound,10,1,2,1
Harry the Harrier,3,6,1,1
Ian the Irish Wolfhound,4,1,1,1
Juno the Jack Russell,9,7,8,2
Keith the Kerry Blue,9,1,10,6
Larry the Labrador,8,2,6,2
Marge the Maltese,4,6,9,2
Max the Mutt,3,10,10,1
Nutty the Newfoundland,7,7,10,8
Olive the Old English Sheepdog,6,9,5,6
Peter the Pug,10,3,10,1
Poppy the Pekingese,10,3,5,9
Rosie the Rottweiler,10,7,9,7
Ruby the Retriever,1,8,4,5
Sam the Springer Spaniel,3,6,7,7
Sukie the Saluki,7,3,8,9
Vernon the Vizsla,7,10,5,2
Whilma the West Highland Terrier,1,5,7,7
William the Whippet,7,9,7,9
Yolande the Yorkshire Terrier,4,5,5,4
okay
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program
{
// Reads in a list of dogs
// IMPORTANT:
// The file "dogsdata.txt" MUST be saved in the same folder
// as this program
static List<string[]> ReadInList()
{
var theList = new List<string[]>();
// Read the file "dogsdata.txt"
using (var reader = new StreamReader("dogsdata.txt"))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line != null)
{
var values = line.Split(','); // Assumes the file is comma-separated
theList.Add(values);
}
}
}
return theList;
}
// Use this for testing that the full list is imported
static void PrintList(List<string[]> aList)
{
foreach (var item in aList)
{
Console.WriteLine(string.Join(", ", item)); // Joins the array with commas for printing
}
}
// Add your subroutines here
// START OF MAIN PROGRAM
static void Main(string[] args)
{
// Read in the list first
List<string[]> dogsList = ReadInList();
// Uncomment the next line once you know it works
PrintList(dogsList);
}
}
that's the program he gave us t owork off of
i looked at it and said fuck that and started my own
Do we need to give the user the option to shuffle or can we implement it if we want it?
hmm, dont think so, whatever is written on the page is written he didn't say do anything else nor extra
Okay thats fine, im close to finish ig
I will send it in here then
And explain
yeah i think it's just subroutines and if statements
thanks so much, so nice of you lmao
yeah but if you wanna give the teacher the thinking that you improved (if beginner level) use switch case statements
np bro, thats also fun to me xD
yeah i know switch case but they are so annoying to me for some reason lol
i think im pushing intermediate level like just below that id say
ik for me too xD
ah sorry missed that xD
Do you have a job in computing or are you still a student
Nah year 13 student
started late in year 12 with computer science
when did u start?
awesome
i started doing python in year 10 for computer science in school but in year 12 we learn C# and i love it so i sped aheah of the class but i think they're catching up now lmao, i started learning C# about the end of September
nice!
I also speeded up at year 12 but there was someone who already did full year 12 in year 11 so I had no chance xD
Can i send you a friend request, seem like a chill dude lol?
np
send u one
yeah my friend has been programming since he was like 9, he is super good at it and nothing else lol, it's crazy what he can do in his free time but only if he put the effort in and leanred the computer science theory he would be an A* student lol
lol
what career do you want to go down? Software engineer?
yeah theory is the hardest part, I got 96% in practical computer science in both predicted exams but I am on an A due to theory
bruh i got a D
then a C on the recent one
i hate the theory or practical bit
both?
but I need to admit, I was the same at start of y12
nah both practice exams
we do these things called "caps" which is just like a practice exam and my teacher says "On the next cap there will be no programming so you're welcome" and im just so annoyed because programming is the one thing i actually like doing
haha that is shit, nah we have one practical and another theory teacher so we learn both and get tested on both
yeah our actual exams are like that
my actual Psychology exam is on Wednesday so i'm not exited for that
I'm trying to grow on twitch aswell so that doesn't help
oh no
xD
Nah I streamed for a little bit xD
what do you stream
I would focus on exams this week
minecraft bedwars xD
i gave up on bedwars ages ago
are you german? just from ur bio
yeah i am german (:
sick ive got a german friend
haha
ill talk later im jst going to eat my lunch
brb
np see ya
finished with coding, now I just need to check if there are any errors in the code
okay im back
That's great! thanks so much
np
ill show u what i've done so far bc why not
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
namespace Actual_dog_game
{
internal class Program
{
static void Main(string[] args)
{
int x = 0;
string[,] myarray = new string[30, 5];
string filepath = "C:\Users\euang\Downloads\DogGameFile\dogsdata.txt";
using (StreamReader reader = new StreamReader(filepath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string[] filearray = line.Split(',');
myarray[x, 0] = filearray[0];
myarray[x, 1] = filearray[1];
myarray[x, 2] = filearray[2];
myarray[x, 3] = filearray[3];
myarray[x, 4] = filearray[4];
x++;
}
}
Console.Write("----------------\r\n Celebrity Dogs\r\n----------------\r\n\r\nEnter your name: ");
string name = Console.ReadLine();
Console.WriteLine($"\nWelcome to Celebrity Dogs, {name}!\n");
Thread.Sleep(1000);
Console.Write("Menu:\r\n1 -> Play Game\r\n2 -> View Random Dog Card\r\n3 -> Quit\n\nOption: ");
int option = Convert.ToInt32(Console.ReadLine());
bool flag = true;
while (flag)
{
if (option == 1)
{
}
else if (option == 2)
{
}
else if (option == 3)
{
Console.WriteLine("Quitting game...");
Thread.Sleep(1500);
Environment.Exit(0);
}
}
Console.ReadKey(); } } } that's what i did so far
Console.ReadKey(); } } } that's what i did so far
okay interesting
wait
oh forgot to comment it
wow thanks
this will work in .NET right?
should be but it is .net 7.0 because no mac support anymore for vs
Not the best code but works, found some errors so those should be fixed
if u have questions or I should explain it further, just ask (:
@cone
sorry i went and did something
ill put in on now
Nah thats fine xD
I think the quit option does work right now but Im in the car so I will fix it later
my only issue now is the dogsdata.txt
it doesn't work for some reason
i've put them in the same folder but they dont seem to be working
Ah okay I could know the issue
I need to get to my pc, pls give me 1/2 an hour, I will ping you when I sent the fixes solution if that is okay
yeah that's fine no worries
we can even call later if u need to explain
Read the path.
It is loading it from a relative path.
You should never work with absolute paths unless you absolutely have to
Always prefer relative
In this case the file must exist in the directory being spat out by the error message
Absolute paths meaning
C:/Users/YourName/Desktop/Foobar.txt
And relative being relative to current working directory. In this case, where the executable is.what should i change and how do i do it
this hs been the main issue for a while now
Filepath. If you define the path as
foobar.txt
without specifying a drive letter such as dogs/foobar.txt
, that makes it relative.so instead of "dogsdata"
how will it know to open that text file then
This path is correct, this is relative.
This however is absolute
okay gimmi a minute
So in the case of absolute, there must be a user named
euang
and must have a folder called DogGameFile
and a file inside of that directory called dogsdata.txt
And if it's relative, you only need a file called dogsdata.txt
in the same path as the executable (by default)my only question is why isn't it working then because there IS a user named euang and a folder called DogGameFile and all that, by all means im happy to change absoloutely anythig i just like knowing how and why
You mean this?
yeah i think
Read the path that it seeks in.
It seems like you aren't reading what I explained or you aren't understanding it.
sorry but i think im not understanding
im new to C# and visual studio and suff
Show the path
that?
LMAO ignore the image at the top of the screenshot there's context
Ok, compare that path to this
what's the difference between path and location
This is in downloads, while it wants a completely different path / location.
No difference
"C:\Users\euang\Downloads\DogGameFile\dog game with help from german guy.cs" thats my clipboard when i copy the path
Wait look
how do i fix it
So where have h stores the data with those dogs?
downloads -> DogGameFile
oh shit did that guy leave
i think he got sick of it
xD
i genuinely didn't understand what he was on about ðŸ˜
Can u send me a screenshot of the path of the dog data file?
😂
Okay, i think i know why
Can u open a new Project in vs?
yes
Yup .net framework
Then replace the existing code in this project with mine
okay done
Now go to the folder where the new project is stored
i called it "temporary"
Thats fine (:
Go in the folder -> bin ->… until u are in the .net … folder and then paste the dog data file in there
Or debug
in bin
there's "debug"
Then paste it in debug (:
Macos is little bit different (:
can i drag and drop
Yep ig
okay done
should i run the code
Yep
Does it work?
yes almost everything works, just when the computer runs out of cards this happens
try it with a while loop instead of do while maybe
could be a silly mistake on my side
no no
stop
i didnt start dw
&& instead of ||
alr
in the do while loop
okay it works for me
Sickkk
thanks sm
no problem
ive officially completed all my hw now, you helped loads
and explained way better than that guy
Thats great!
Thanks xD
how come Germans are so good at speaking English
I am a boarder at a school in england
but because those languages are quite similar
english is just way easier in grammer etc
yeah i realised English is a germanic language
😄
yeah i tried learning german but i gave up
where are you in the UK?
understandable, I woud too xD
Cotsworlds
u?
I'm in Manchester
nice (:
not far from u loll
yep xD
were you born in germany
munich
in the south east
ahh cool my mum has a degree in german she used to live there
my friend lives in Hörstel
oh thats great!
i think it's near the netherlands border
yep
just looked it up xD
her english is so good i dont even understand how or why
haha
alright im gonna revise now, ill message u again if i need anything or have a problem
thanks!
yes sure!
hang on
np i loveit to help others
sometimes my code goes white? like the word "Console" it goes white and its all colourless
how could i fix that
Hmm
I also had that sometimes
hang on
When you have that go: Tools > Options > Text Editor > C# > Advanced and select "Visual Studio 2019" in the Editor Color Scheme dropdown
that should fix it
yeah okay, it's not happened currently but ill do it if it happens again
Okay (:
also, do you mind following me on twitch? i'm just trying to gain followers desperately lol
No problem
wait
u have a link or sth like that?
btw I will also revise now, but maths xD
@cone
oh sorry gimmi a sec
np
oh gta nice!
I will have a look when u stream soon
i like maths but A level maths is too hard man
wish i took it now tho
instead of psychology and sociology
okay xD
u dont like them?
im streaming at about 8pm
okay, should be there