class VotingSystem { constructor() { this.votes = new Map(); } vote(voterId) { if (this.votes.has(voterId)) { console.log("您已经投过票了!"); } else { this.votes.set(voterId, true); console.log("投票成功!"); } } getTotalVotes() { return this.votes.size; } }