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
John Doe
Level 18
london
  • 10.01.2020
  • 826views
  • 4comments

I really don't know what I miss on this exam can someone help me please ?

Question about the task Wine tasting
Java Core,  Level 4,  Lesson 8
Archived


1. Create an abstract Drink class with an implemented public void taste() method that displays "Delicious".
2. Create a Wine class that inherits Drink and implements a public String getCelebrationName() method that returns "Birthday".
3. Create a SparklingWine class that inherits Wine and implements a public String getCelebrationName() method that returns "New Year's".
4. Write implementations for the getDeliciousDrink, getWine, and getSparklingWine methods.
5. All the classes must be in separate files.

Requirements:
  • The abstract Drink class must be in a separate file.
  • The Drink class must implement a public void taste() method that displays "Delicious".
  • The Wine class must be in a separate file and be a descendant of the Drink class.
  • The Wine class must implement a public String getCelebrationName() method that returns "Birthday".
  • The SparklingWine class must be in a separate file and be a descendant of the Wine class.
  • The SparklingWine class must implement a public String getCelebrationName() method that returns "New Year's".
  • The Solution class must implement the getDeliciousDrink() method, which returns a Wine object.
  • The Solution class must implement the getWine() method, which returns a Wine object.
  • The Solution class must implement the getSparklingWine() method, which returns a SparklingWine object.
package com.codegym.task.task14.task1410; /* Wine tasting */ public class Solution { public static void main(String[] args) { getDeliciousDrink().taste(); System.out.println(getWine().getCelebrationName()); System.out.println(getBubblyWine().getCelebrationName()); System.out.println(getWine().getCelebrationName()); } public static Drink getDeliciousDrink() { return new Drink(); } public static Wine getWine() { return new Wine(); } public static Wine getBubblyWine() { return new BubblyWine(); } }
0
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
John Doe
Level 18 , london, England
10 January 2020, 21:16useful
Thank you very very much for your help ! It's better than give the solution now i will take care of the name of my methods all the time thank you again !
+1
John Doe
Level 18 , london, England
10 January 2020, 20:31
Thank you very much but unfortunatly it doesn't fix the problem
0
klesk
Level 31 , Duisburg, Germany
10 January 2020, 20:43useful
Ok, i found some other little thinks.
The Wine class must implement a public String getCelebrationName() method that returns "Birthday".
Your method is called getCelebration(), same with BubblyWine. In your Solution class you are calling .getCelebrationName(). Also
The Solution class must implement the getDeliciousDrink() method, which returns a Wine object.
but your methode returns a Drink object. I hope this time it will help.
+2
klesk
Level 31 , Duisburg, Germany
10 January 2020, 20:26
The abstract Drink class must be in a separate file.
I would guess, maybe there is your problem. Your Drink class is not abstract.
+2
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.