课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Challenge: Data structures - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Challenge: Data structures
(upbeat music) - [Narrator] The exercise for this chapter is going to be to implement a basing voting system for people voting for contestants, for example, on a TV show. So you'll see there's a class in here called VotingSystem. And in the codes there are some comments that explain what you should do to complete the exercise. So first of all, you should create a field which will be a LinkedHashMap and this will store the name of the contestant as the key and the number of the votes as the value. Then you should implement the vote method so that when a contestant name is passed in, the number of votes is incremented by one. And finally, you should update the getVotes method to return the map that you created at the top rather than a new empty map. So to check that your code is working, there are some unit tests that you can run. So inside the folder, test, Java, for example, in _03_05, there's a class called VotingSystemTest.…