✅ I need help with building a project named train station system
I feel a bit confused about how to start the project, that's why I need help
113 Replies
$main
$mains
$mains
The possible signatures for
Main
are public
is not required (can be any accessibility).
Top-level statements are compiled into a Main
method and will use an appropriate signature depending on whether args
is referenced, the await
operator is used and/or an explicit return
statement is used.
https://docs.microsoft.com/en-US/dotnet/csharp/fundamentals/program-structure/main-command-lineMain() and command-line arguments
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
you put code in the main method?
what are these methods you wrote above lol
seems a bit confusing
these are signatures
I mean you posted something and you shoed me something else 🤷🏻♂️
for the main method
Ok
but what why do I need all these methods then?
you didn't know how to start
you start by putting your code in main
Ah! Ok! Sorry my brain fog is totally missed up.
I guess I asked the wrong question
what I mean is that the project seems a bit confusing to me
not where to start 😄
it's kind of complicated
well it break down then
what are the high level steps you need to take
?
that's why many people say we need to break down our project into small steps. You're definitely right. That's why it feels so dame confusing.
well! I don't know what would be these steps.
I mean from what I see the goal of the project is to create a program/ app that can check how many passengers rides, stays and get off, right?
and they have specified a limited numbers based on the recommendations
max 40 passengers are allowed to be in the train
well skim the image you sent
what are the two big glaring things?
that are each even on separate lines
capacity 40 & 10 stations
right?
no
input and output
Ok
how do you get from input to output?
what do you get as a result of input?
by getting user input and then print out the result
I get the output
how do you get the results?
well
I'm expecting a high level answer
if I'm intending to perform some condition statements for user input then I could print the output
well kinda. the answer I was expecting is "we have to apply certain transformations / processing to the user input"
Ok
that's right
alright so the three big things are input -> processing -> output
yes sir
is any user input valid?
nope
so you also have to validate the user input
by setting guard
input + validation -> processing -> output
throwing exception
this is the structure that you should use for all your programs
really
that's very interesting to learn
this is analogous to functions too
they take parameters -> apply validation or contracts -> do some logic -> return the result
you're right. This is what I've been doing in all my projects and you just showed me the simple flow
now break down which part of the problem goes into which category
man you are incredibly awesome in transforming confusing stuff into more clear understandable stuff, i really like learning with you
that's a really good question
this problem goes to the train driver getting passengers record/ number of how many the enter the train, get off and exist currently, right?
this should be the primary step of the program getting passengers data
first step is to get tge data form the user and do the validation
that's correct
do you know what confused me most
every time I build a project, I set and think! Should I use properties, method, list/array or plain condition statements.
this is my problem
for example, look what I have don so far.
I don't mean to overwhelm you with too much stuff
you got busy or something?
the simplest thing is just plain structs
do everything in you main method
treat objects as just groups of variables
whatever you have is not right
since you know so little, stay away from OOP and properties and constructors and stuff like that
you create an object, you set public fields, you use the data stored in the fields
forget instance methods exist
every method should be static
otherwise you are definitely going to get overwhelmed
Ok! Great.
do you think my knowledge is bad at these, I don't think so. I know how these work, but my problem is just not knowing if they are the right option for the specific project.
what do you mean here?
don't use instance methods because they will confuse you more
at least for the time being
it's always the same for simple projects. you define the data (the train struct or class) and then you do operations on the data (calling static methods passing in the data, or just calculating things inline)
Ok! You mean by calling methods and use them through an instantiating an object? When am I going to learn them if I don't practice them then?
"you do operations on the data" you mean applying the condition statements, right?
no I mean static methods. do you know what static methods are?
I mean the processing part
I've watched some tutorials on it, isn't that I don't need to instantiate an object, but I could call the method directly from the
class Train
?yes and you should use them at te beginning. I suggest you don't use instance methods
make a static method and pass the train as a parameter
you don't completely understand the idea of parameters yet
don't jump into OOP unless you have that down at least
+ procedural programming is so so much easier to understand for a beginner
(yeah I misread the message hence I'm rewording some stuff)
I do understand parameter and arguments and OOP and all that, but I don't know the
why
and this is why I get confused sometimes and I think it requires more experience like by building a various of projects.
like for .e.g why should pass parameters in the method?how else do you pass a value into a piece of code?
methods without arguments would be significantly less useful
Oh! That was very interesting to know, you're right.
why the hell we use methods if they don't enable us to print out any value.
you can stick a
Console.WriteLine();
in any method you want, but a lot of the time you dont actually want thatodd to make a variable of Train Array
stations
a Train is a Train, why each Train should know the number of Trains ?You're right. I can print out any value using the static method invocation and
Console.WriteLine();
great to see you show up bro
recently, I started a new project from my previous course I took although it's written in Swedish.Plenty of people here read swedish just fine, if you have detailed instructions in swedish, but as you probably know we prefer all communication over official channels are in english .)
it seems a bit confusing to me where to start and what to do
seems to me your input is a text file
or possibly a series of inputs to STDIN (Console.ReadLine())
but I'd develop based on a text file
easier to test
that's right. English is the main language when it comes to programming
the first row in the file is two numbers separated by a space
what do you mean by that?
text file?
this project feels complicated to understand what they want
a little bit, sure
they just say "the first input contains two numbers..."
they dont really specify in what format that input will be
its usually either a file or STDIN, which are both streams - so you can actually code in a way that supports both.. but that might be harder to use for a beginner
input of what?
it doesnt say.
thats all it says
yeah! This is what confused me most my friend. I took this course online and I had a teacher called David, he used not offer any help that's why I failed at the course.
bad teachers are dime a dozen, I'm afraid
that's right. I was very disappointed to waste 3 months on the course.
I mean all I understood is that, they want me to create a program where its features distinct with getting input data and do calculation + comparing for these data and then print out the result/ values of these data so when any new passengers need to ride in the train the the driver would check if there's available seats then the app would display if possible or not possible.
am I seem right or wrong do you think?
something along those lines
the first line of input is the trains capacity AND the total number of stations
the rest of the lines are each one station
with each station having number of people who
get OFF the train
get ON the train
are left behind
the next part of the assignment that confuses me most is the 10 stations, don't really know what purpose of these stations 🤷🏻♂️
your goal is to return a boolean variable: if this "route" is valid or not
according to the rules
Ok
I understood is that if the train contains 1 - 40 passengers then it's fall, we can't take in any more passengers not possible, they're gonna wait for the next train.
you could do this in many ways, and the faster/simpler ones are probably not using OOP here
but you certainly CAN use OOP if you want
Ok! Wow, that's very satisfying to see. I don't expect to get any code snippet, since I need to practice logical skill, but some tips/ hints or any guidance would be appreciated 🙂
Step 1, parse the input.
Step 2, make a method that rakes the parses input in and returns the bool out
Ok! I should be able to use the snippet that you provided me yesterday. https://discord.com/channels/143867839282020352/143867839282020352/1082372654864015460
Pobiega#2671
Quoted by
<@!973964186956726313> from #chat (click here)
React with ❌ to remove this embed.
Depends?
You dont need that snippet if you go with the file route
and even then, your core algorithm (aka the actual problem solving) should probably just take parsed input in
I'd probably start out with something like this
@Faraj
Ok! I'm not really sure what you mean by file route?
as in, store the input as a file
you've only sent screenshots of the instructions, so I can't tell for sure, but it seems reasonable to have a file with stuff like
I'm not sure what this code is doing! I see that you're throwing exceptions.
yeah, thats a special exception that just means.. "this method isnt done yet"
meaning you should replace it with the code that does what the method should do
this is just a simple console application not using any framework just you know
didn't really understand what you mentioned here
what are those numbers for? 🙂
Did you read the instructions? 😛
yes, the above code is indeed for a console app..
Ok! But it seems a bit advanced code to me.
its really not.
its not OOP in any way, its just using methods and your own types (the records at the bottom)
like you're using bool in the methods which I've never used and you're using record which I haven't seen before
bool
is the datatype for the values true
and false
it can only ever be one of those two. thats it.
its the simplest data type there is 🙂I know but you're using it in declaring method
sure? but its just a data type
a method that returns a bool isnt different from a method that returns a string, or an
int
are you using some overriding methods?
its just the return type.
nope. not at all
Ok
its just two static methods (not counting Main), in a static class. thats it.
records are like classes, but immutable (cant be changed) by default
and have this nifty syntax that is really short 🙂
its just a good way to make types for data
Ok
so the goal of this code is to?
its just a boilerplate, a starting point
the goal is that you would replace the "throw new..." lines with actual code that does what the methods say they do
and then when you run the program, it would solve the train problem
I'm sure you've heard "break down the problem" a million times by now
Ok! That seems clear to me now.
this is that. ive broken down the problem once, into two parts
of course many times
part 1: reading and parsing the input
part 2: solving the actual problem
this is a very common first step, as you want to separate the reading and understanding of your inputs from the actual logic
Ok
now, as you solve these two parts, you'll likely want/need to create new methods to help solve the individual parts. thats fine, you are just further breaking down the problems
Ok! You know what my friend, I really would like to call you just a 15 minutes so I can understand a bit more clearly, that way I don't need to spend many days on building only one simple project, is it ok?
sure, lets go to #dev-vc-1
awesome man, thanks a lot.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.👍