Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Netbeans Create a class named LuckyNumber that has the following instance variables: - String name - int luckyNumber This class should only have a

In Netbeans Create a class named LuckyNumber that has the following instance variables:

- String name

- int luckyNumber

This class should only have a single overload constructor that:

- takes a single parameter, name

- automatically assigns luckyNumber a random number between 0 and 9 (inclusive of both) to the instance being created

This class must have the following methods:

- getName

- get luckyNumber

- toString

o make sure your toString returns the class name

o the class name will be useful if you become lost in your data structure

- equals

This class should not have the following methods:

- set name

o you are who you are

- set luckyNumber

o you cant change your luck

Step 2:

Create a class named LuckyNumberList that will contain a LinkedPositionalList of LuckyNumber objects.

This class should contain a constructor and methods similar to the Alphabet class in the IteratorExample1 project.

- Unlike the Alphabet class your constructor should just create an empty LinkedPositionalList

- You will need to add a addLuckyNumber method to this class

o This method has a single parameter of type LuckyNumber.

o this method should add the new entry at the end of the list.

- It will be the job of the client class to add entries into the list.

You will be adding two custom iterators:

- an iterator that iterates over the positions in the list that have an even LuckyNumber

- an iterator that iterates over the positions in the list that have a prime LuckyNumber

- Note, if you use the Alphabet class as a guide you will remove the VowelPositionIterator. Actually, you may find it helpful to modify the VowelPositionIterator into one of the above required iterators.

Step 3:

Create a client class named Client that does the following:

- Creates an instance of your LuckyNumberList class.

- Fills the list with at least ten (10) names.

o You can hardwire the fills into your code by using ten calls to addLuckyNumber that pass new instances of LuckyNumber objects.

o Names can be hardwired into your code.

- Prints out the resulting contents of your instance of the LuckyNumberList class using:

o The default iterator that displays all entries in the list

o The Prime iterator that displays only the entries in the list that have prime luckyNumbers

o The Even iterator that display only the entries in the list that have even luckyNumbers.

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_2

Step: 3

blur-text-image_3

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions