Maven Apache - Java

Hello. I need guidance regarding an assignment from free pre-internship program for Java that i just joined. I wasn't able to get to the first meeting because I had an exam that i couldnt miss, so now i'm pretty much left empty-handed and I have to complete it in less than 20hours.
Our first assignment is in the picture.
I have to make use of "Maven Apache" to complete this task. I barely started learning Java and now I paused that process to learn what and how to use Maven. How would u create this app? I'm not asking for source code or anything. Just how would u approach this? What would u use (if you were to use basic things from Java) ?
I'm really a beginner to this whole thing, but I also want to learn and hopefully make my way a little higher. Thank you.

Attached: maven.png (618x331, 21K)

Other urls found in this thread:

stackoverflow.com/questions/29965764/how-to-parse-json-file-with-gson?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa)
maven.apache.org/guides/getting-started/maven-in-five-minutes.html
my.mixtape.moe/zmwyvs.zip
udemy.com/java-the-complete-course/
udemy.com/java-the-complete-java-developer-course/
en.wikipedia.org/wiki/Neurobiological_effects_of_physical_exercise
twitter.com/AnonBabble

>the remained products

hello pajeet.

Since you need to use maven, I'd use it for importing a json parsing libary.
Then you create two .json files, one for the bank notes + coins, one for the products and their price

When program starts, read the two files and parse the json to java objects.
Then just print out the stock, make a loop that reads input (Scanner class) and reacts to the command inputs (commands you will likely need will be "select x from stock", "add x coin/banknote to payment" and "pay")

Honestly, this is really easy. If you have no clue how to do this already, you are fucked.

also you could use maven to make it an executable jar

> fuck my grammar mistakes
> remaining products*

When you say i'm fucked... how fucked? Because I barely started learning Java. Barely heard of "json". Is there some newbie way of making this? They're supposed to get us through this kind of thing later i suppose. Maybe make use of an ArrayList, or HashList or smth similar? Or many classes?

barely got myself into what is supposed to be maven. They didnt ask us to do "testing" or anything. just to have the "pom.xml" file and the "src" with the app.

jesus kid. you're fucked.

so... any easier (for me) to create this?
It's 3am and I got less than 20h, but I'm ready to learn whatever I need to know.

use eclipse and create a new maven project? probably need a plugin like m2e or whatever it was called.

yup, already onto that. How would i solve the assignment using a more "primitive" method ?

>Maybe make use of an ArrayList, or HashList or smth similar?

If you don't even know what data structures best to use for this (hint, it's a map) then you're fucked and this isn't assignment that you can reasonably do in 20h, since it seems you are a complete newb.

You need to learn how to:
a) Read files
b) Translate those files into data you can deal with
c) Populate a data structure with that data (HashMap for Stock (key is item name, value is item object with price + remaining units), Set for coins/banknotes)
d) Read input, parse that input and react to input (Scanner class, scanner.nextLine() in a loop)
e) use maven somehow, which you can use to build your program and make an executable jar or add dependencies(google it, check if you want to use gson stackoverflow.com/questions/29965764/how-to-parse-json-file-with-gson?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa)

How are you suddenly at a stage of having less than 20 hours? When were you given this task?
Just want an idea of expected depth from the original time frame, they'll have different expectations depending on if you've had a week or a day to do this

Thank you. Will get into it ASAP. hopefully i'll make it work somehow.
Long-story short: Assignment was given on Thursday morning, I had an exam since then, some essays to do, and to travel to my hometown and back to college. I'm studying Economics and IT, but hardly any IT... like really basic shit. In this "pre-internship" thing are enlisted students from IT Faculty and some other technical/ IT things Faculties (those were they also teach you Physics). I'm gonna finish this one way or another.

>wasn't able to get to the first meeting
and didn't make an arrangement with someone else in that was in the meeting
you'd better have learned this valuable, and expensive (in terms of stress), lesson
because in the future, planning fuckups like this will get more expensive

Honestly for this, he could just use serializable on some map holding class and call it a day instead of dealing with json/whatever serialization

don't waste what little time you have with json (and the library mess) yet, you've got relatively flat data
just go
- products.csv - comma separated list of product name, stock and price
- banknotes.txt - types of banknotes, one on each line
- coins.txt - likewise, for coins

>products.csv - comma separated
or space separated, whichever one is easiest to parse
you may want to rearrange it to have the product name as the last column in that case, in case you want to support spaces in the names
remember - get something working first, do it fancy later, but avoid getting stuck in spaghetti code

OP I'm gonna do your assignment now, drop your discord

>Since you need to use maven, I'd use it for importing a json parsing libary.
nah, fuck that overcomplication, it's additional risk for the dude
just use it for building
OP, read this, do it for a hello world prog (sans tests for now), then get cracking on the actual project
maven.apache.org/guides/getting-started/maven-in-five-minutes.html

I hardly know what a hashmap is, but would it be the thing you're talking about? I really need some "primitive" way to solve this. They're definitely not making us solving this assignment in some expert, or least to say, experienced way. They already know our level of Java and judging by the other ppl i saw there, it was very, very low. So there must be a much easier way for sure. Like simply creating some classes and making a few connection here and there.
I really dont think I need to go through this. I think it must be much easier way for me.
daydreamer#7557

don't do it for him, at the most give him guidance
nigga needs to get some sort of lesson out of this, otherwise it's wasted money/opportunity
>I think it must be much easier way for me.
what do you have in mind?

jesus dude, that English
now I'm curious which country are you from?

I wouldn't like it that much for someone to do the assignment for me. I'd still need to know what's in there.

> easier way
Something more primitive... like an ArrayList holding the name of products, currencies and everything. They dont expect much from us to be fair. The interview was pretty basic. Didn't have anything related to JSON or something similar.

this is my "it's 3:24am, I'm overly stressed and I don't have that much time left to pay attention to, say, a few minor grammar mistakes."- English.

>Something more primitive

writing serialized objects using the native "serializable" interface is about as "primitive" as you can get. lol

anyhow fuck man. do you even java at all? yikes dude. try and find some maven console app archetype or something. fuck you probably can't even figure that out. dude. just fuck. youre fucked unless that cuck really comes through for you, but being this is Jow Forums Jow Forums I'd probably write it in scala or some other lang and fuck you over kek.

>Didn't have anything related to JSON or something similar.
yep, that guy didn't know at what level you guys are
>Something more primitive... like an ArrayList holding the name of products, currencies and everything
sure, that'll do
if classes aren't too advanced for you, *after you get shit working*, you can refactor the product arrays (names, stock, prices) into a class with three fields.
ah yeah, I know the one
>3:24am
>overly stressed
Ah, memories. Thank fuck that part's behind me.
No worries m8, you'll manage. Keep this thread alive tomorrow and we might be able to continue providing guidance.
But after getting this shit done and getting some much needed rest, consider improving your planning.

>3:24am
GMT+3, huh? You in E.Europe or something?

>serializable" interface is about as "primitive" as you can get
*if* they've learned about
- interfaces
- serialization
otherwise, just reading line-delimited files might be simpler

continuing
>3:24am
>less than 20 hours
So what's your deadline? Sunday 23:59 GMT+3 or earlier?

I really think they dont expect us to do advanced things. On the prep-interview we had we were asked the most basic things about Java. Like what is encapsulation, inheritance, how do they work; a little bit polymorphism. Really not much. Some SQL related questions. And surprisingly the short English presentation we had to give was were I aced.
>GMT+3, huh? You in E.Europe or something?
Romania, to be more precise.

Some guy that was there told me a few hours ago that it should be done till Sunday night.
It's not that much of a big deal if i send it on Monday morning. They're cool and all.

>Some guy that was there told me a few hours ago that it should be done till Sunday night.
>It's not that much of a big deal if i send it on Monday morning
Great.
I'd strongly suggest getting 8 hours of sleep now and starting this tomorrow (start a thread and keep us posted), unless the discord dude has other plans.

Ah, he didn't contact me or anything. But it's cool. If I don't find some other way around it, I'll just quickly learn how to use hashmaps or something that'll help me finish the assignment.
I'd give more time to this whole thing If I had more of it, but I'm already without a social life, and hardly ever getting rest. Im lucky I live with my best friend (along with 3 other dudes in the college dormitory).
Guess i'll take your advice and get a 4* hours sleep.
Thank you for everything so far. There are nice people on Jow Forums after all...

>I'll just quickly learn how to use hashmaps or something that'll help me finish the assignment.
no need for those, unless I'm missing something - you can just prompt the user to enter the product id
keep it simple until you've got it working

post a thread (and keep it alive) tomorrow if you feel you could use some hints, I'll probably swing by in about 10 hours

Will do. Thank you again :)

no probs m8
no guarantees I'll be here tho

Honestly with a database and SQL or whatever this would be extremely easy to do, we use a bunch of apache shit at work but I still don't know how half of it works doesn't help they all have shit documentation

it's a trivial task, sans the UI. The guy's got a limited time and knowledge budget, so adding unnecessary stuff is only going to increase the risk of him not getting shit done.

Maven is just a Java build tool that uses a particular folder and path convention. So as long as you have a pom.xml with the basic tags, a src/main/java folder with all your Java source code, and a src/main/resources folder with anything you want to parse and read, you can use maven from the command line to package the application into a .jar.

maven.apache.org/guides/getting-started/maven-in-five-minutes.html

You can use the command line to build a project folder structure using a maven archetype.

OP, dude writing your program here:
Should change be considered when paying?

I think OP went to sleep. Far as I can tell that's not a requirement (neither is checking if the user payed the actual amount required).

Well OP, your discord is wrong.
Here's your homework
my.mixtape.moe/zmwyvs.zip

Thank you for the time spent. I've tried to read the code; you made it very readable, but this is obviously made by a professional. I'll try to catch up with some more Java tutorials, then recreate (if possible) everything there in my own (but similar) way.
Thank you so much.
I didn't really manage to run it though because I have no idea where I should run the command "java -jar shop-1.0-shaded.jar D:\mypath\zmwyvs\items.txt D:\mypath\zmwyvs\money.txt" ... I really dont think the first assignment is this hard considering the technical interview they've put us through where the other guys hardly even knew what the concepts of OOP. We talked a little bit about "What kind of lists we know -> ArrayList, HashList, etc", then something about "builders" which I had no idea about. Their writing test wasn't that hard either, although they had a good amount of things I had no idea about....

I'll try to recreate it the way I can, not the "correct", or least to say, not the way someone, that actually knows what the hell, would do.

>dat mixed tabs and spaces
>dat pajeet indentation
>trailing whitespace
holy fuck fix yer editor
>silently ignoring invalid lines
hmm
>dat verbosity, then again this is Java

I keed tho.
Still, OP's probably gonna want to actually do his shit by himself.
Then again, your code can be very useful as guidance.

Hey OP, hope you got some shuteye.
>java -jar shop-1.0-shaded.jar D:\mypath\zmwyvs\items.txt D:\mypath\zmwyvs\money.txt
Ought to do it, but backslashes might be fucking your shit up. If you get any path issues, just dump the jar and two text files into the same directory, cd into it and try `java -jar shop-1.0-shaded.jar items.txt money.txt`

That guy's code is very handy, at the very least as a guide on how to do the file parsing and command handling.
You can start your own version by taking inspiration from those two parts, implementing the minimum set of commands (so you have something working for at least the basic flow), then adding more commands if time permits.
Make sure you smoke-test often, preferably use version control (or keep a copy of the last working version somewhere).

Managed to run it, as you said, by adding the 2 text files inside the folder.
Can you recommend me a few videos that'd made me understand the code ? I'm currently running through a tutorial from Udemy (Java.Complete.Course). I need to get through ~60 more videos till I get to Hashsets though. Watching on 1.5x Speed; got some coffee; So I'm ready to go.

How long are the videos in total?
Not sure about the videos, though I'd recommend trying to implement a shittier version with the knowledge they're expecting you to have at the moment.
Do the guys expect you to know about sets and maps?

>Udemy (Java.Complete.Course)
Is it this one
udemy.com/java-the-complete-course/

udemy.com/java-the-complete-java-developer-course/
this one (Didn't buy it, if that's the concern)

Nah, more about what's the content.
Try starting from what you need, instead of watching it from the start to the end. A kind of a on-demand knowledge acquisition strategy, in a way.
E.g. "I haven't a clue what hashsets are." -> watch the hashset video. When you hit something you don't understand (and is important for figuring out hashsets enough to get shit working) - ask questions here, regardless of how retarded, or skim the other videos to find the info.

I think yes, but I have no idea how to use them, yet*, neither. Would take a while to watch all the videos from the course, but as I said, I have all day free for that. Im going to be straight with you, I feel like i should message the coordinator and tell him what does he expect from me, and if I can possibly make it throughout the whole course they're doing to prepare us for internships.
mhm, sounds like a better idea than what I had in mind, considering the fact that my time is running out. What do you think? Can I make it through this whole thing? I'm already dedicating most of my time to studying. I can dedicate even more. I just want to know if I have any chances "to make it out alive"

>message the coordinator and tell him what does he expect from me, and if I can possibly make it throughout the whole course they're doing to prepare us for internships.
That's a nice idea if things get too hairy.
I'm assuming this is something bootcamp-ish.
Had a friend who did something similar and decided to drop out halfway through, which was a shame since I think he could've powered through with some (mental) assistance.
>Can I make it through this whole thing?
Assuming the OP pic is the entirety of the requirements, and with some guidance to prevent you from going into dead ends, sure.
Don't know the level of polish/features these folks expect, so you probably won't get high marks, but considering you're doing in a day what should've been done in (how much time?), I'd say it's expected.
Without guidance? Dunno, depends on your approach.

Now, down to brass tacks. A faster comms medium to discuss this without wasting time would be ideal, but that'd take some time to set up.
Back to text:
- which parts of the problem (and the code from that dude) do you understand and feel you can recreate relatively quickly, e.g.
- reading a file
- reading and parsing the file
- reading, parsing the file and adding to a data structure (an ArrayList)
- reading, parsing the file and adding an item to the shop object
Likewise for the shopping cart, command handler and so on.
Or just list a few of the things you don't understand (can't recreate) from the problem: e.g. hashsets, scanners, whatever.

However, from a time perspective: I'd recommend going for an iterative implementation strategy, as in:
- you don't have a lot of time
- you have a better chance of having something working, if you start implementing immediately, and tack on the _minimum_ required functionality as needed, in the least risky way possible (e.g. fuck hashsets and maps, start with arraylists first).
- after some time (e.g. an hour or two of doing this), pause and re-evaluate your chances
[contd]

continued
- I recommend you post your progress here, so we can warn you whether it would make sense to contact the coordinator.

Actually, if you want to demonstrate professionalism, you can choose to contact them now, and give them a heads up, something like
"Hey folks, I fucked up the scheduling and am now trying to do this problem in under a day. Just wanted to give you a heads up, since I figure it's better to warn you before the submission date. I should've done this earlier, but I'll try to do better, scheduling and warning wise, next time."

Alright, I'm off to do some RL shit, be back in half an hour.
In the meantime, try to start implementing yo shit, e.g. via
- that Maven in 5 minutes link with a hello world
- writing the file parsers, having them dump all the info on screen
- switching to storing the info in a bunch of arraylists
- starting on the UI (with the *minimum* command set you need, don't get fancy)

I can understand the connection that had been made here and there, but I wouldnt be able to re-create it from scratch by myself.
For the moment i'll try to stick with watching a couple of videos, then I'll try to do something myself. I had a C# programming class last semester where I was taught "the basics of the most basic shit in programming". I few weeks ago I started getting myself into Java, but unfortunately the other classes I have to make projects, attend, and study for are slowing me down.

I hardly know what parsing is (but Google is my best friend); very little information on ArrayLists(again that's why im going very fast through this tutorials right now); I have no idea how to create the UI.

Getting there. Digging it. At this point I don't even care if I'm going to be late with the assignment as I'm still going to put all my cards on the table when I meet one of the coordinators, the next time I get the chance.

You probably have no idea (actually you might do) how much you're helping me with this... with everything. I have a pretty shitty life, from desperately trying to find love, existentialism crises at 3am, some insomnia, writing depressing poems, struggling to study Economics (something I hate the most, but I'm already on my 2nd year ( 2/3 years) and now to this. And this is one of the things that actually make it worth it; that actually bring me some joy in the misery; the fact that I might be able to do something I like, or least, something I will* enjoy.
Thank you.

>I hardly know what parsing is (but Google is my best friend);
In this case, just reading the files.
>very little information on ArrayLists
Fancier arrays/lists, like in C#
>I have no idea how to create the UI.
It's going to be a loop of:
1. Print a prompt for the user ("gimme yo command: ")
2. Read a line into a string, which will contain the user's command
3. Validate the command (split on spaces, check if we recognize it with a bunch of ifs, print an error message if not)
4. If valid, do whatever the command asks you to - quit, purchase a product, whatever
4a. For each of those actions, you have a bunch of ifs to check if it's possible - e.g. if the product is out of stock, print an error message and return
5. Go back to step 1.

You can see the code for that in Shop.handleCommand()

>You probably have no idea (actually you might do) how much you're helping me with this... with everything. I have a pretty shitty life, from desperately trying to find love, existentialism crises at 3am, some insomnia, writing depressing poems, struggling to study Economics (something I hate the most, but I'm already on my 2nd year ( 2/3 years) and now to this.
Been there, done that in most regards.
- situational depression's a bitch, non-situational even more so. Note that situational depression in college/uni is very common due to the shit job they do preparing you for the self-sufficiency/organization requirements of college/uni. Shit got better in my case once the stressors were mostly out, hopefully will in yours too.
- I notice that sleep debt really shits on my emotional control and often tends to put me in semi-depressive states. Test if that's a contributing factor in your case (no sense in playing the depression game on hard mode). Likewise for psychoactive substances (coffee, alcohol and so on)
- Try to gradually build a support network, shit helps (there's a lot to expand on here, but I'm running out of space)
Keep it up m8, showing up is half the battle

>At this point I don't even care if I'm going to be late with the assignment as I'm still going to put all my cards on the table when I meet one of the coordinators, the next time I get the chance.
That's a good approach to take, but if I may offer a suggestion: give a heads up to the coordinator if you're planning on submitting after the deadline. Ideally, you'd be able to have a live, face to face chat with them before the deadline and go
- I fucked up the scheduling, I'm working on it right now and will continue until it's finished, I can't say if I'll be able to submit something working before the deadline
- I can submit whatever I have when the deadline drops, and continue until I have something working, at which point I can send it in if it makes sense
Or something of the sort. Ideally you don't want to lose brownie points by having your coordinators think you don't respect their time, the rules, etc - but obviously you don't want to be asking for favors/special treatment.

I'm itching to translate this to [muh pet language] for shits and giggles, but then again shitposting's so much better bang for buck.
Off to dpt, I guess.

Sad, but somewhat happy, to hear others that went through something I'm going through right now... mostly sad though.
I was thinking of creating the basic interface by printing out a welcoming message then asking the user for input regarding what he wants to do (i.e. see the list of products (which then he'll have the choice of leaving the "Shop";
buy something (which then will ask him to pay and choose how will he pay (how much change should i give back);
Then ask if he wants to purchase more or leave the shop. If he wants to purchase more, a list of all the products and how much is left in the Stock of the shop.
And the whole thing will repeat.
Should be good? Thinking of going with just some ArrayLists, some classes here and there, getters, setters. Nothing fancy at all. And if it's not what they wanted, oh well. Will explain then everything and ask them to teach me and have some patience.
Will do that right now.

Thank you

>Sad, but somewhat happy, to hear others that went through something I'm going through right now... mostly sad though.
I understand the feeling, I've been there. Try to rule out the easy stuff that may be making this harder for you (sleep, decent diet, 1-2h cardio a week [1]).
[1] en.wikipedia.org/wiki/Neurobiological_effects_of_physical_exercise - just 2h/week (at least 10 minute spans) of getting your heart rate up to 65-85% max is a very decent way to get some mental gains.

As for the harder stuff, some of it may be temporary (college/uni/work stressors), and if so, by god does it become better once those are reduced. If it's less situational, seek others' experiences, but avoid going into downward spirals (e.g. getting more depressed by hanging out in Jow Forumsdepression too much).

>UI
So in summary, the program will go like
1. Print welcome banner
2. Prompt user to choose
a) list products
b) purchase
c) quit
If the user chooses b), it'll prompt him which product ID, then how many, then will ask him to somehow enter how he will pay. If everything's valid, it'll adjust the product's stock.
Then it'll loop back to 2.
Is that about right?
>Thinking of going with just some ArrayLists, some classes here and there, getters, setters. Nothing fancy at all
Sounds good, you can even start with public fields just to get shit running (with FIXME: switch to getters/setters comments), then upgrade to getters/setters once you have a working version committed / as a copy somewhere.
>Will explain then everything and ask them to teach me and have some patience.
Depends on your phrasing/approach. Right now it sounds like you'd demand their time (them teaching you, slowly), despite this setback not being their fault.
I'd suggest something more to the tune of "I'll share with them my plan to catch up by myself, and hope that they can offer suggestions on how to improve it; and if they have the time, keep them posted so they know if I'm falling behind my plan".

> Jow Forumsdepression
Well, my only close friend is somewhat on the same ship with me, except he really doesnt give a shit about anything, but memes are our way of actually having a good couple of laughs... there's also video games. The others ppl I rarely hang out with... well yah.. i gotta fake it all with them.

>UI
Sounds more than right.

I've talked with the main coordinator and bought a little bit more time.
>I'd suggest something more to the tune of [...]
pretty much what i had in my mind. Thanks God there's a 1 week break coming up (Easter break). I'll have more time to study.

Hopefully i'll manage to finish this and everything will go accordingly. Really, thank you for all :)

no probs m8, and good luck
>only close friend is somewhat on the same ship with me
Keep up the friendship, we're social animals after all. Do have some self-defense though, keep an eye out for behaviors that drag you down along with him. And if you get the chance from time to time, do some shit with the dude to break up the monotony (nature, experiences) - whatever experiences still make you feel good.
>others ppl I rarely hang out with... well yah.. i gotta fake it all with them.
That's the case with most, just the way it is.

See if you can change up the scenery from time to time - explore new areas in and out of the city, try different activities, don't be afraid to do them alone.
Bah, this shit is just the same old platitudes without knowing specifics.
In any case, g'luck