Git Product home page Git Product logo

java-fix-counting-hash-set's Introduction

ByteLegend Challenge of JavaIsland: OOP, Inheritance

English

Fix the Bug in CountingHashSet Implementation

Credit: This example is from the book Effective Java Item 16: Favour composition over inheritance by Joshua Bloch.

We want to build a HashSet, which can count the number of elements added since the creation of the instance, but the current implementation src/main/java/com/bytelegend/CountingHashSet.java has a bug, please understand and fix it.

CountingHashSet is a HashSet with all the features of HashSet plus the ability to count the number of elements added since the creation of the instance.

  • You can accomplish this challenge via any way below:
    • Recommended for beginners: run git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set to download the code, finish the challenge in your local IDE, then copy/paste/submit the answer in web editor.
    • Very unrecommended: you can click here to download zipped code if you don't like git operations.
    • Or: if you are confident enough to write code in web editor directly, go ahead.
    • Or: if you are familiar with GitHub, you can fork the repo, finish the challenge and create a pull request.
  • The bot will check your PR and tell you if you accomplish the challenge.
  • Go back to ByteLegend and continue your hero journey.

Good luck!

If you need any help, feel free to join the Discord Community or contact us via [email protected].

Note: we only allow you to modify the following files. Any changes to files other than the following files will be rejected:

  • src/main/java/com/bytelegend/CountingHashSet.java
简体中文

修复CountingHashSet实现中的Bug

鸣谢:这个例子来源于《Effective Java》的组合优于继承Favour composition over inheritance一节,作者是Joshua Bloch。

我们希望创建一个HashSet,能够统计"有史以来"添加的元素数量,但是现在的实现src/main/java/com/bytelegend/CountingHashSet.java有明显的Bug,请思考并修复之。

CountingHashSet拥有HashSet的全部功能,此外,它还可以统计"有史以来"添加过的元素的个数。

  • 你可以使用以下任意一种方法完成挑战:
    • 初学者推荐:运行git clone https://git.bytelegend.com/ByteLegendQuest/java-fix-counting-hash-set将代码下载到本地,在本地使用IDE调试完成后复制到网页编辑器里提交。
    • 非常不推荐:如果你实在不喜欢git命令行操作,你可以点击这里直接下载打包好的代码
    • 或者:如果你非常自信不需要下载代码到本地调试,可以使用网页编辑器直接提交。
    • 或者:如果你对GitHub非常熟悉,你可以fork这个仓库、完成挑战后,创建一个Pull Request。
  • 机器人将会检查你的答案,告诉你你是否通过了挑战。
  • 回到字节传说,然后继续你的英雄旅程。

祝你好运!

如果你需要任何帮助,欢迎加入官方玩家QQ群(在首页右下角的联系 & 关于菜单里可以找到入群方式)或者Discord社区,或email至[email protected]

注意:我们只允许您修改以下文件,任何对其他文件的修改都会被拒绝:

  • src/main/java/com/bytelegend/CountingHashSet.java
繁體中文

修復CountingHashSet實現中的Bug

來源:這個例子來自 Joshua Bloch 所著的《 Effective Java Item 16: Favor composition over inheritance 》一書。

我們想構建一個HashSet ,它可以統計自創建實例以來添加的元素數量,但是當前實現src/main/java/com/bytelegend/CountingHashSet.java有一個bug,請理解並修復。

CountingHashSet是一個HashSet ,它具有HashSet的所有特性,以及計算自創建實例以來添加的元素數量的能力。

  • 您可以通過以下任何方式完成此挑戰:
    • 推薦給初學者:運行git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set下載代碼,在本地 IDE 中完成挑戰,然後在網頁編輯器中復制/粘貼/提交答案.
    • 非常不推薦:如果你不喜歡git操作,可以點擊這裡下載壓縮代碼
    • 或者:如果您有足夠的信心直接在 Web 編輯器中編寫代碼,請繼續。
    • 或者:如果你熟悉 GitHub,你可以 fork倉庫,完成挑戰並創建一個拉取請求。
  • 機器人會檢查你的 PR 並告訴你是否完成了挑戰。
  • 回到ByteLegend繼續你的英雄之旅。

祝你好運!

如果您需要任何幫助,請隨時加入Discord 社區或通過[email protected]聯繫我們。

注意:我們只允許您修改以下文件。對以下文件以外的文件的任何更改都將被拒絕:

  • src/main/java/com/bytelegend/CountingHashSet.java
Español

Solucione el error en la implementación de CountingHashSet

Crédito: Este ejemplo es del libro Elemento 16 de Java eficaz : Favorecer la composición sobre la herencia de Joshua Bloch.

Queremos construir un HashSet , que pueda contar la cantidad de elementos agregados desde la creación de la instancia, pero la implementación actual src/main/java/com/bytelegend/CountingHashSet.java tiene un error, entiéndalo y corríjalo.

CountingHashSet es un HashSet con todas las funciones de HashSet más la capacidad de contar la cantidad de elementos agregados desde la creación de la instancia.

  • Puede lograr este desafío de cualquier manera a continuación:
  • El bot verificará tu PR y te dirá si logras el desafío.
  • Regrese a ByteLegend y continúe su viaje de héroe.

¡Buena suerte!

Si necesita ayuda, no dude en unirse a la comunidad de Discord o contáctenos a través de [email protected] .

Nota: solo le permitimos modificar los siguientes archivos. Cualquier cambio en los archivos que no sean los siguientes archivos será rechazado:

  • src/main/java/com/bytelegend/CountingHashSet.java
العربية

إصلاح الخلل في تنفيذ CountingHashSet

الائتمان: هذا المثال مأخوذ من كتاب Java Effective Item 16: التأليف المفضل على الميراث لـ Joshua Bloch.

نريد إنشاء HashSet ، والذي يمكنه حساب عدد العناصر المضافة منذ إنشاء المثيل ، لكن التنفيذ الحالي src / main / java / com / bytelegend / CountingHashSet.java به خطأ ، يرجى فهمه وإصلاحه.

CountingHashSet هو HashSet مع جميع ميزات HashSet بالإضافة إلى القدرة على حساب عدد العناصر المضافة منذ إنشاء المثيل.

  • يمكنك إنجاز هذا التحدي بأي طريقة أدناه:
    • موصى به للمبتدئين: قم بتشغيل git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set لتنزيل الكود ، وإنهاء التحدي في IDE المحلي الخاص بك ، ثم نسخ / لصق / إرسال الإجابة في محرر الويب .
    • غير موصى به على الإطلاق: يمكنك النقر هنا لتنزيل رمز مضغوط إذا كنت لا تحب عمليات git .
    • أو: إذا كنت واثقًا بدرجة كافية لكتابة التعليمات البرمجية في محرر الويب مباشرةً ، فابدأ.
    • أو: إذا كنت معتادًا على GitHub ، فيمكنك تفرع الريبو وإنهاء التحدي وإنشاء طلب سحب.
  • سيتحقق الروبوت من العلاقات العامة الخاصة بك ويخبرك إذا أنجزت التحدي.
  • ارجع إلى ByteLegend وتابع رحلة بطلك.

حظا طيبا وفقك الله!

إذا كنت بحاجة إلى أي مساعدة ، فلا تتردد في الانضمام إلى مجتمع Discord أو الاتصال بنا عبر [email protected] .

ملاحظة: نسمح لك فقط بتعديل الملفات التالية. سيتم رفض أي تغييرات يتم إجراؤها على الملفات بخلاف الملفات التالية:

  • src/main/java/com/bytelegend/CountingHashSet.java
Português

Corrija o bug na implementação do CountingHashSet

Crédito: Este exemplo é do livro Effective Java Item 16: Favor composição sobre herança por Joshua Bloch.

Queremos construir um HashSet , que pode contar o número de elementos adicionados desde a criação da instância, mas a implementação atual src/main/java/com/bytelegend/CountingHashSet.java tem um bug, por favor entenda e corrija.

CountingHashSet é um HashSet com todos os recursos do HashSet mais a capacidade de contar o número de elementos adicionados desde a criação da instância.

  • Você pode realizar este desafio de qualquer maneira abaixo:
    • Recomendado para iniciantes: execute git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set para baixar o código, termine o desafio em seu IDE local e copie/cole/envie a resposta no editor da web .
    • Muito não recomendado: você pode clicar aqui para baixar o código zipado se não gostar das operações do git .
    • Ou: se você estiver confiante o suficiente para escrever código diretamente no editor da web, vá em frente.
    • Ou: se você estiver familiarizado com o GitHub, você pode bifurcar o repo , finalizar o desafio e criar um pull request.
  • O bot verificará seu PR e informará se você cumprir o desafio.
  • Volte para ByteLegend e continue sua jornada de herói.

Boa sorte!

Se precisar de ajuda, sinta-se à vontade para se juntar à Comunidade Discord ou entre em contato conosco via [email protected] .

Nota: só permitimos que você modifique os seguintes arquivos. Quaisquer alterações em arquivos que não sejam os arquivos a seguir serão rejeitadas:

  • src/main/java/com/bytelegend/CountingHashSet.java
Bahasa Indonesia

Perbaiki Bug dalam Implementasi CountingHashSet

Kredit: Contoh ini dari buku Efektif Java Butir 16: Mendukung komposisi daripada warisan oleh Joshua Bloch.

Kami ingin membangun HashSet , yang dapat menghitung jumlah elemen yang ditambahkan sejak pembuatan instance, tetapi implementasi saat ini src/main/java/com/bytelegend/CountingHashSet.java memiliki bug, harap dipahami dan diperbaiki.

CountingHashSet adalah HashSet dengan semua fitur HashSet ditambah kemampuan untuk menghitung jumlah elemen yang ditambahkan sejak pembuatan instance.

  • Anda dapat menyelesaikan tantangan ini melalui cara apa pun di bawah ini:
    • Direkomendasikan untuk pemula: jalankan git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set untuk mengunduh kode, selesaikan tantangan di IDE lokal Anda, lalu salin/tempel/kirim jawabannya di editor web .
    • Sangat tidak direkomendasikan: Anda dapat mengklik di sini untuk mengunduh kode zip jika Anda tidak menyukai operasi git .
    • Atau: jika Anda cukup percaya diri untuk menulis kode di editor web secara langsung, silakan.
    • Atau: jika Anda terbiasa dengan GitHub, Anda dapat melakukan fork repo , menyelesaikan tantangan, dan membuat permintaan tarik.
  • Bot akan memeriksa PR Anda dan memberi tahu Anda jika Anda menyelesaikan tantangan.
  • Kembali ke ByteLegend dan lanjutkan perjalanan pahlawan Anda.

Semoga berhasil!

Jika Anda memerlukan bantuan, jangan ragu untuk bergabung dengan Komunitas Discord atau hubungi kami melalui [email protected] .

Catatan: kami hanya mengizinkan Anda untuk mengubah file berikut. Setiap perubahan pada file selain file berikut akan ditolak:

  • src/main/java/com/bytelegend/CountingHashSet.java
Français

Correction du bogue dans l'implémentation de CountingHashSet

Crédit : Cet exemple est tiré du livre Effective Java Item 16 : Favor composition over heritage par Joshua Bloch.

Nous voulons construire un HashSet , qui peut compter le nombre d'éléments ajoutés depuis la création de l'instance, mais l'implémentation actuelle src/main/java/com/bytelegend/CountingHashSet.java a un bogue, veuillez le comprendre et le corriger.

CountingHashSet est un HashSet avec toutes les fonctionnalités de HashSet plus la possibilité de compter le nombre d'éléments ajoutés depuis la création de l'instance.

  • Vous pouvez accomplir ce défi de n'importe quelle manière ci-dessous:
    • Recommandé pour les débutants : lancez git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set pour télécharger le code, terminez le défi dans votre IDE local, puis copiez/collez/soumettez la réponse dans l'éditeur Web .
    • Très déconseillé : vous pouvez cliquer ici pour télécharger le code compressé si vous n'aimez pas les opérations git .
    • Ou : si vous êtes suffisamment confiant pour écrire du code directement dans l'éditeur Web, continuez.
    • Ou : si vous êtes familier avec GitHub, vous pouvez forker le dépôt , terminer le défi et créer une demande d'extraction.
  • Le bot vérifiera votre PR et vous dira si vous accomplissez le défi.
  • Retournez à ByteLegend et continuez votre voyage de héros.

Bonne chance!

Si vous avez besoin d'aide, n'hésitez pas à rejoindre la communauté Discord ou à nous contacter via [email protected] .

Remarque : nous vous autorisons uniquement à modifier les fichiers suivants. Toute modification de fichiers autres que les fichiers suivants sera rejetée :

  • src/main/java/com/bytelegend/CountingHashSet.java
日本語

CountingHashSet実装のバグを修正

クレジット:この例は、JoshuaBlochによる「 EffectiveJavaItem 16:Favorcompositionoverinheritation 」という本からのものです。

インスタンスの作成以降に追加された要素の数をカウントできるHashSetを構築したいのですが、現在の実装src / main / java / com / bytelegend / CountingHashSet.javaにはバグがあります。理解して、修正してください。

CountingHashSetは、 HashSetのすべての機能に加えて、インスタンスの作成以降に追加された要素の数をカウントする機能を備えたHashSetです。

  • この課題は、以下のいずれかの方法で達成できます。
    • 初心者に推奨: git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-setを実行してコードをダウンロードし、ローカルIDEでチャレンジを終了してから、Webエディターで回答をコピー/貼り付け/送信します。
    • 非常に推奨されていませんgit操作が気に入らない場合は、 ここをクリックしてzipコードをダウンロードできます。
    • または:Webエディターで直接コードを記述できる自信がある場合は、先に進んでください。
    • または:GitHubに精通している場合は、リポジトリをフォークしてチャレンジを終了し、プルリクエストを作成できます。
  • ボットはPRをチェックし、チャレンジを達成したかどうかを通知します。
  • ByteLegendに戻り、ヒーローの旅を続けてください。

幸運を!

ヘルプが必要な場合は、 Discordコミュニティに参加するか、contact @bytelegend.comからお問い合わせください。

注:変更できるのは次のファイルのみです。次のファイル以外のファイルへの変更は拒否されます。

  • src/main/java/com/bytelegend/CountingHashSet.java
Русский

Исправить ошибку в реализации CountingHashSet

Предоставлено: этот пример взят из книги Джошуа Блоха « Эффективная Java , пункт 16: предпочтение композиции перед наследованием ».

Мы хотим создать HashSet , который может подсчитывать количество элементов, добавленных с момента создания экземпляра, но в текущей реализации src/main/java/com/bytelegend/CountingHashSet.java есть ошибка, пожалуйста, поймите и исправьте ее.

CountingHashSet — это HashSet со всеми функциями HashSet , а также возможностью подсчета количества элементов, добавленных с момента создания экземпляра.

  • Вы можете выполнить эту задачу любым способом, указанным ниже:
  • Бот проверит ваш PR и сообщит, выполнили ли вы задание.
  • Вернитесь в ByteLegend и продолжайте свое героическое путешествие.

Удачи!

Если вам нужна помощь, присоединяйтесь к сообществу Discord или свяжитесь с нами по адресу [email protected] .

Примечание: мы разрешаем вам изменять только следующие файлы. Любые изменения в файлах, кроме следующих файлов, будут отклонены:

  • src/main/java/com/bytelegend/CountingHashSet.java
Deutsch

Beheben Sie den Fehler in der CountingHashSet Implementierung

Quelle: Dieses Beispiel stammt aus dem Buch „ Effective Java Item 16: Favor Composition Over Inheritance “ von Joshua Bloch.

Wir möchten ein HashSet , das die Anzahl der seit der Erstellung der Instanz hinzugefügten Elemente zählen kann, aber die aktuelle Implementierung src/main/java/com/bytelegend/CountingHashSet.java hat einen Fehler, bitte verstehen und beheben Sie ihn.

CountingHashSet ist ein HashSet mit allen Funktionen von HashSet plus der Möglichkeit, die Anzahl der Elemente zu zählen, die seit der Erstellung der Instanz hinzugefügt wurden.

  • Sie können diese Herausforderung auf eine der folgenden Arten meistern:
  • Der Bot überprüft Ihre PR und teilt Ihnen mit, ob Sie die Herausforderung meistern.
  • Gehen Sie zurück zu ByteLegend und setzen Sie Ihre Heldenreise fort.

Viel Glück!

Wenn Sie Hilfe benötigen, können Sie sich gerne der Discord Community anschließen oder uns über [email protected] kontaktieren .

Hinweis: Wir erlauben Ihnen nur, die folgenden Dateien zu ändern. Alle Änderungen an anderen Dateien als den folgenden Dateien werden abgelehnt:

  • src/main/java/com/bytelegend/CountingHashSet.java
한국어

CountingHashSet 구현의 버그 수정

출처: 이 예는 Joshua Bloch의 책 Effective Java Item 16: Favor composition over 상속 에서 발췌한 것입니다.

인스턴스 생성 이후 추가된 요소의 수를 셀 수 있는 HashSet 을 만들고 싶지만 현재 구현된 src/main/java/com/bytelegend/CountingHashSet.java 에는 버그가 있으므로 이해하고 수정하십시오.

CountingHashSetHashSet 의 모든 기능과 인스턴스 생성 이후 추가된 요소 수를 계산하는 기능을 갖춘 HashSet 입니다.

  • 아래 방법을 통해 이 챌린지를 완료할 수 있습니다.
    • 초보자에게 권장: git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set 을 실행하여 코드를 다운로드하고 로컬 IDE에서 챌린지를 완료한 다음 웹 편집기에서 답변을 복사/붙여넣기/제출합니다. .
    • 매우 권장하지 않음: git 작업이 마음에 들지 않으면 여기를 클릭하여 압축 코드를 다운로드 할 수 있습니다.
    • 또는 웹 편집기에서 직접 코드를 작성할 만큼 자신이 있다면 계속 진행하십시오.
    • 또는 GitHub에 익숙하다면 리포지토리를 분기 하고 챌린지를 완료하고 풀 요청을 생성할 수 있습니다.
  • 봇은 PR을 확인하고 도전 과제를 달성했는지 알려줍니다.
  • ByteLegend 로 돌아가 영웅 여정을 계속하세요.

행운을 빕니다!

도움이 필요하면 언제든지 Discord 커뮤니티 에 가입하거나 [email protected] 을 통해 문의하세요.

참고: 다음 파일만 수정할 수 있습니다. 다음 파일 이외의 파일에 대한 변경 사항은 거부됩니다.

  • src/main/java/com/bytelegend/CountingHashSet.java
Italiano

Risolto il bug nell'implementazione di CountingHashSet

Credito: questo esempio è tratto dal libro Efficace Java Item 16: Favor composition over heritance di Joshua Bloch.

Vogliamo creare un HashSet , che può contare il numero di elementi aggiunti dalla creazione dell'istanza, ma l'attuale implementazione src/main/java/com/bytelegend/CountingHashSet.java ha un bug, per favore comprendilo e correggilo.

CountingHashSet è un HashSet con tutte le funzionalità di HashSet più la possibilità di contare il numero di elementi aggiunti dalla creazione dell'istanza.

  • Puoi portare a termine questa sfida in qualsiasi modo di seguito:
    • Consigliato per i principianti: esegui git clone https://github.com/ByteLegendQuest/java-fix-counting-hash-set per scaricare il codice, completa la sfida nel tuo IDE locale, quindi copia/incolla/invia la risposta nell'editor web .
    • Molto sconsigliato: puoi fare clic qui per scaricare il codice zippato se non ti piacciono le operazioni git .
    • Oppure: se sei abbastanza sicuro da scrivere il codice direttamente nell'editor web, vai avanti.
    • Oppure: se hai familiarità con GitHub, puoi eseguire il fork del repository , completare la sfida e creare una richiesta pull.
  • Il bot controllerà il tuo PR e ti dirà se hai superato la sfida.
  • Torna a ByteLegend e continua il tuo viaggio da eroe.

In bocca al lupo!

Se hai bisogno di aiuto, non esitare a unirti alla community di Discord o contattaci tramite [email protected] .

Nota: ti permettiamo solo di modificare i seguenti file. Eventuali modifiche ai file diversi dai seguenti file verranno rifiutate:

  • src/main/java/com/bytelegend/CountingHashSet.java

java-fix-counting-hash-set's People

Contributors

0x00650a avatar 18211384978 avatar andrewbaxter439 avatar andyliukun avatar bytelegendbot avatar greek-zzf avatar gtn1024 avatar guakun01 avatar humansdonotwantimmortality avatar jenny-2233 avatar johnsonxiaoyu avatar keranbingaa avatar lemon-altxx avatar ov0o0vo avatar pamaomaoa avatar pipiloveslife avatar saveunhappy avatar tomcat-guo avatar xxldm avatar youngerkayn avatar zerofancy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.