+ 1
Can anyone help me with final project of SoloLearn Java Course?
This is the Project I have to build. You are creating a bowling game! The given code declares a Bowling class with its constructor and addPlayer() method. Each player of the game has a name and points, and are stored in the players HashMap. The code in main takes 3 players data as input and adds them to the game. You need to add a getWinner() method to the class, which calculates and outputs the name of the player with the maximum points. Sample Input: Dave 42 Amy 103 Rob 64 Sample Output: Amy
19 odpowiedzi
+ 1
Just one trick is to store the name of the winner also in another String variable, whenever you find a new max inside the loop.
Declare your variables local, inside the method.
public void getWinner(){
int maxPoint = 0;
String winner = "";
for(String x : player.keySet()){
if(maxPoint < players.get(x)){
maxPoint = player.get(x);
winner = x;
}
}
System.out.println(winner);
}
+ 4
1. Review the lesson about the HashMap
2. You can also look at additional sources online, how to use a hashmap, I always find Baeldung to have great articles about any topic
https://www.baeldung.com/java-hashmap
Plus the JDK documentation is your friend. Keywords for google: jdk 17 hashmap
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/HashMap.html
3. You can iterate through the hashmap keys, or through the entries (which contain the key and the value at the same time).
Example:
for (String name: players.keySet()) { ... }
4. Use a loop to keep track of the highest scoring player (name and score in separate variables)
+ 2
Sure, let me review what you have so far. Can you copy your getWinner method?
+ 2
Tibor Santa
Here is the method:
int maxPoint = 0;
public void getWinner(){
for(String x : player.keySet()){
if(maxPoint < players.get(x)){
maxPoint = player.get(x);
}
}
System.out.println(maxPoint);
}
+ 2
As for YouTube, I noticed the links I post to YouTube are not working from the Sololearn app.
So I will just suggest you two accounts (channels):
freecodecamp.org
They have lots of Java learning videos, some for beginners. I am sure you will find some that fit your learning style and level.
Devoxx
This is a coding conference and they post videos of tech talks. I highly recommend the lectures by Venkat Subramaniam. His talks are very informative, he uses modern Java, functional programming and reactive programming. He always does live coding during his talk too. Maybe not the best one for complete beginners though, but he offers a lot to learn.
I watch a lot of tech talks on YouTube... Not only Java. :)
+ 2
I don't have any Java Android resources for you, as I am not an android developer.
But I think if you are interested in mobile, you should consider picking up Kotlin. The industry is moving away from Java to Kotlin, at least Google is pushing this really hard. They also offer courses and tutorials, you should look around here:
https://developer.android.com/courses
+ 2
Java is not needed to learn Kotlin.
Kotlin is a great language on its own too, but it also runs on the Java Virtual Machine, and it has easy ways to interact with Java code.
You already have some basics of Java, so Kotlin will look quite familiar, but it's syntax is more modern and fluid, with less ceremony and less "boilerplate" - which sort of means code that you must write just because the sake of OOP tradition, like getters and setters, or hashcode method.
Kotlin lets you get rid of this boring stuff, and focus on the essentials.
+ 2
I work as a consultant, not a coder. But programming is in high demand, we also have trouble with recruitment, very difficult for us to find good developers. I cannot advise on money, that would depend much on individual skill, and job opportunities in your area.
There are a lot of interesting areas in programming, in my opinion some that are really important right now:
- Web applications. Lot of modern software is offered as SaaS (software as a service) in a subscription model and accessed through a web browser.
- Cloud computing and edge computing. Infrastructure is no longer maintained by each individual company but rented from cloud providers such as AWS, Azure, GCP.
- Machine learning. Lot of data is generated and stored all the time, but making sense of them and using them to the company's advantage is an art. AI is becoming more prevalent in all types of businesses applications.
+ 1
Tibor Santa
I can iterate it and can find the highest score but the only problem is that I could not print the key of the player that has the highest score.
If you help me I will appreciate it
+ 1
Tibor Santa
Here the question is how do I print the key of maxPoint.
maxPoint is the value.
+ 1
Tibor Santa
Thank you sir
it finally works and I got my certificate.
Do you have some YouTube tutorials recommendations to learn Java?
+ 1
Thank you Sir
+ 1
Thank you sir for your time and replies
I really appreciate it
0
Ok wait
0
Do you know the roadmap of how to become an android developer?
0
For learning Kotlin, is learning of Java is needed or not?
0
Ok I will learn that.
one final question
0
According to your experience , besides people interest What is a good career in programming that has good money and big future?
0
Hi