Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi guys, I just want to make sure I have this code correctly. I like when someone check my work, and see if I did

Hi guys,

I just want to make sure I have this code correctly. I like when someone check my work, and see if I did all requirements.

Here the assignment:

Make a generic method that has an argument/parameter that only allows a Star Wars Character or an extension of a Star Wars Character. The body of the method will be updated in the JavaFx final project component. You will use these java files to test your generic method.

It come with this java code file too:

GenericsStarWar.java

public class GenericsStarWars {

//write your generic method here

}

Main.java

public class Main {

Yoda yoda = new Yoda();

ObiWan obiWan = new ObiWan();

Mickey mickey = new Mickey();

GenericsStarWars gsw = new GenericsStarWars();

//call your method here with the above objects

Mickey.java

public class Mickey {

}

ObiWan.java

public class ObiWan {

private String name = "Obi-Wan";

}

StarWarsCharacter.java

public class StarWarsCharacter {

private String name = "Generic Star Wars Character";

public String getName() {

return name;

}

}

Yoda.java

public class Yoda extends StarWarsCharacter {

private String name = "Yoda";

}

Here Is my code: (Please correct me or leave a comment on what I did wrong. Thanks in advance. )

class Mickey{

}

class ObiWan extends StarWarsCharacter{

private String name = "Obi-Wan";

}

class StarWarsCharacter{

private String name = "Generic Star War Character";

public String getName() {

return name;

}

}

class Yoda extends StarWarsCharacter{

private String name = "Yoda";

}

class GenericsStarWars{

public void starWarsOnly(StarWarsCharacters Characters) {

}

}

public class BB8Droid {

public static void main(String[] args) {

Yoda yoda = new Yoda();

ObiWan obiwan = new ObiWan();

Mickey mickey = new Mickey();

GenericsStarWars gsw = new GenericsStarWars();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions