CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Michal
Level 26
Lodz
  • 11.06.2020
  • 341views
  • 2comments

This entire course is a joke

Question about the task New functionality!
Java Multithreading,  Level 5,  Lesson 2
Under discussion


Using an enum, implement the getLetterPosition() method, which must return a letter's position.
The position of the letter A is 1.

Requirements:
  • The Solution class must have an enum called Alphabet.
  • Alphabet must contain the 26 letters of the English alphabet, in alphabetical order.
  • The Alphabet class's getLetterPosition() method must return a letter's position in the alphabet.
  • The getLetterPosition() method must call the ordinal method.
package com.codegym.task.task25.task2501; /* New functionality! */ public class Solution { public static void main(String[] args) { System.out.println(Alphabet.G.getLetterPosition()); } public enum Alphabet { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z; private int ordinal; public int getLetterPosition() { return Alphabet.this.ordinal + 1; } } }
0
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
WIDMO
Level 41 , Gdańsk, Poland
30 June 2020, 16:36
You should remove, 19 line:
private int ordinal;
and change 22 line to :
return Alphabet.this.ordinal() + 1;
remember that ordinal is a method, so you need to put brackets.
0
Eelke 't Hooft
Level 27 , Amsterdam, Netherlands
22 June 2020, 08:17
Should be fine if you remove the private int ordinal.
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.