C
C#4mo ago
biskit

Building a console app for a uni assignment and struggling

Having serious trouble coding this console app in c# and would appreciate help, I have a UML diagram to use
37 Replies
Jimmacle
Jimmacle4mo ago
$details
MODiX
MODiX4mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
biskit
biskitOP4mo ago
Sorry, new here ^^" I need to create a console app that functions as a food delivery app (Just eat, Uber Eats etc...) Needs to be able to read from a selection of files formatted in a particular way, split those files into various different strings to use as names, ingredients,prices and recipes for fooditems. Also need to be able to add fooditems into an order etc
Jimmacle
Jimmacle4mo ago
alright, which part are you getting stuck on?
biskit
biskitOP4mo ago
Mainly the file reading, not sure how to split the file as its in quite an annoying format, also cant seem to get the current directory of the file so instead have to hardcode the directory which sucks
Jimmacle
Jimmacle4mo ago
do you have an example of the format and the code you're trying to use to find the files?
biskit
biskitOP4mo ago
Name:Slow Food Emporium Toppings:[<cheese,80>,<tomato sauce,40>,<bbq sauce,40>,<peppers,40>,<pineapple,40>,<ham,100>] Garnishes:[<cheese,80>,<bacon,100>,<fried onions,40>] Pizza:<Name:Hawaiian,Toppings:[tomato sauce,cheese,pineapple,ham],Price:550> Pizza:<Name:Margherita,Toppings:[tomato sauce,cheese],Price:500> Burger:<Name:Classic Hamburger,Garnishes:[],Price:350> Burger:<Name:Bacon Burger,Garnishes:[cheese,bacon,fried onions],Price:450> the numbers after the ingredients are the prices of individual ingredients, since youll be able to add extra toppings on items
Jimmacle
Jimmacle4mo ago
i will say this format sucks
The Fog from Human Resources
:SCshocked:
biskit
biskitOP4mo ago
yeah :((((
Jimmacle
Jimmacle4mo ago
were you given any specific tools/guidance on how to parse the file?
biskit
biskitOP4mo ago
not really no, we did basic file reading in one lecture but we were thrown way in the deep end for this one
The Fog from Human Resources
im stunned that unis are such an important part of education and then they pull this :SCgetoutofmyhead:
Jimmacle
Jimmacle4mo ago
so you have a couple of lines that look like they aren't menu items themselves, just lists of options then you have actual menu items that can have optional add-ons from those lists?
biskit
biskitOP4mo ago
yes! so i know that if i read the file and create an array of strings, entry 0 1 and 2 will always be name, ingredients, and garnishes
Jimmacle
Jimmacle4mo ago
are you expecting to be given "bad" files to see if your code rejects it or not? because if not you can probably take some shortcuts
biskit
biskitOP4mo ago
we get to make all the files ourself so nah no need to catch myself out i imagine theyll use one of their own just to make sure we use the same format tho
The Fog from Human Resources
you can make the files yourself but the format you sent is required?
biskit
biskitOP4mo ago
yes!
Jimmacle
Jimmacle4mo ago
my point is what if they give you a file where the order of the first 3 lines are different, or there are invalid characters that don't match the format, etc i don't really understand why they'd use such a complex format if you could get away with ignoring most of it
The Fog from Human Resources
JSON would suite this far more i think.
biskit
biskitOP4mo ago
honestly i imagine a big try catch loop would suffice since its only 1st year
Jimmacle
Jimmacle4mo ago
any standard serialization format would, but if the exercise is to parse this specific thing then that's not really an option
biskit
biskitOP4mo ago
ah ok
Jimmacle
Jimmacle4mo ago
personally i'd start looking at how much of the actual file structure you can ignore if you know the first 3 lines are always name, toppings, garnishes, then strip out all the contents except what you actually care about which are the actual name and the lists of toppings and garnishes then you know those lists have items that are always a name and a price, so get rid of the angle brackets and split it into a plain array where every 2 elements make an item
The Fog from Human Resources
i have a suggestion but idk if its bad or not :SCgetoutofmyhead:
biskit
biskitOP4mo ago
its just super confusing because up until now, projects and labs have been super basic ill take anything!!
Jimmacle
Jimmacle4mo ago
i'm suggesting doing some pre-processing to turn Toppings:[<cheese,80>,<tomato sauce,40>,<bbq sauce,40>,<peppers,40>,<pineapple,40>,<ham,100>] into something like cheese,80,tomato sauce,40,bbq sauce,40,peppers,40,pineapple,40,ham,100 simplify the problem basically all the other garbage doesn't give your program any useful information
The Fog from Human Resources
you know these 3 the rest is kinda dynamic so if those are not provided in this specific order i think it would be an option to hardcode the 3 Keys and treat the rest with the standard serializer youll write so you can avoid line issues if that was what you wanted to go with
No description
biskit
biskitOP4mo ago
sorry had to go get laundry ;-; ill play around with some stuff and see what happens, thank you for the advice guys!
The Fog from Human Resources
just break it into pieces, im assuming you still have time for this so just experiment with it personally i think this is a great approach for it
biskit
biskitOP4mo ago
i do! got a week to finish
The Fog from Human Resources
relatable af frfr
No description
biskit
biskitOP4mo ago
x333 this is my main downfall rn, work and moving house has made it impossible to get this done just so so tired...
The Fog from Human Resources
Nah you'll get there :SCyay:
biskit
biskitOP4mo ago
tyyyyyy i hope so, if i fail this i fail the module :)))
Anton
Anton4mo ago
nah, don't cut corners with the parser they're always straightforward to write, just tedious just bite the bullet and write the most straightforward code you can just try to solve it head on, you'll be surprised how easy it actually is if you just do the thing the most obvious way
Want results from more Discord servers?
Add your server