Build two classes (**Fraction** and **FractionCounter**) and a **Driver** for use in counting the number of unique fractions read from a text file. We’ll also reuse the **ObjectList** class we built in lab to store our list of unique **FractionCounters, **instead of directly using arrays or the **ArrayList**.

Remember

- NO DECIMALS!
- Handle input of any length

Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in one line at a time and build a **Fraction** object from A and B. For each unique **Fraction** seen, your program will create a **FractionCounter** object used to track the number of occurrences of that specific fraction. When all the input is consumed, your program will print out its **ObjectList** of unique **FractionCounters**, which should report the fraction and its count – see output below. You can assume no blank lines or misleading characters; see the text file link above for the some of the input I’ll use when testing your submission. Your program must reduce fractions, as demonstrated in the output below.

6/3

7/3

6/3

2/1

2/1 has a count of 3

7/3 has a count of 1

This class should be a simple abstraction (i.e., a small class) that represents the ratio of two numbers. There will be only two data elements, and only a few methods. Note that it is required for your Fraction class to store your ratio in reduced form, so this is feature to implement in your software.

- The numerator –
*what primitive type makes the most sense here?* - The denominator –
*same type as the numerator.*

**Overloading**- Fraction() – default “no-arg” constructor
- Fraction(int,int) – constructor which initializes your data

**Overriding**- boolean equals(Fraction other) – compares “this” to “other”
- String toString() – replace this inherited method with one appropriate to the class

**Getters & Setters**- getNumerator()
- setNumerator(…)
- getDenominator()
- setDenominator(…)

This class should also be small, and contain only a few state variables. The purpose of this class is to store a reference to a Fraction object and a count of how many times this fraction object has been seen in the input file.

- The Fraction – declare this class variable to be of type Fraction from above
- The counter – the integer value used to count the number of these fractions seen

- FractionCounter( Fraction theFraction ) – constructor
- bool compareAndIncrement( Fraction newFraction ) – used to see if the newFraction passed into this function is the same as the Fraction we’re storing, and if so increments the counter by one and returns true (otherwise, returns false).
- String toString() – replace this inherited method with one that prints out both the Fraction and its count

Error handling

- When encountering illegal data, print an error message, skip the data, and continue processing

Before submitting your assignment, be sure to thoroughly test it – for example, if your software fails to compile, the maximum grade falls to a 75%. Does your software reduce fractions? Test this common case. What about boundary cases or unusual situations? For example, does your software read in the fraction “4/0” and crash with a DivideByZeroException? Can your software handle 0 fractions? 1 fraction? 1,000 fractions? What does your software do with the fraction “-1/-4”? What if the numerator or denominator is very large, as in “1/9999”? Does your program report the fraction “1/1 occurs 4 times” only once (as it should, for the fractions.txt file linked in Fractions V1), or does it report “1/1 occurs 4 times” multiple times (which it should not)? If you store the fraction using doubles, does the equals() function suffer from roundoff errors? Test your code for as many cases as you can think of by varying the “fractions.txt” input file. Note that I will try multiple “fractions.txt” input files when grading your assignment.

NB: You **need to code your program it so it can run with input files besides the example one. **In particular, it has to work with input files that are of any length. **You must enable the appropriate lists to dynamically resize.**

**OBJECT LIST **

**// pseudo code: when adding elementif new count exceeds size{create new larger arraycopy elements from original array into new arrayassign new array to array instance variableupdate maxSize}**

// Minimal interface for this assignment ***

pubic ObjectList()

public void add(Object obj)

public String toString()

**// Complete Interfacepublic String toString()public int indexOf(Object obj)public int getNumElements()public Object getAt(int i)**

Build two classes (**Fraction** and **FractionCounter**) and a **Driver** for use in counting the number of unique fractions read from a text file. We’ll also reuse the **ObjectList** class we built in lab to store our list of unique **FractionCounters, **instead of directly using arrays or the **ArrayList**. Rather than designing a monolithic chunk of code in main like we did in the previous homework, we’ll practice distributing our code into containers (called classes) that you will design specifically to tackle this same problem in a different and more logically organized fashion.

Remember

- NO DECIMALS!
- Handle input of any length

Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in one line at a time and build a **Fraction** object from A and B. For each unique **Fraction** seen, your program will create a **FractionCounter** object used to track the number of occurrences of that specific fraction. When all the input is consumed, your program will print out its **ObjectList** of unique **FractionCounters**, which should report the fraction and its count – see output below. You can assume no blank lines or misleading characters; see the text file link above for the some of the input I’ll use when testing your submission. Your program must reduce fractions, as demonstrated in the output below.

6/3

7/3

6/3

2/1

2/1 has a count of 3

7/3 has a count of 1

This class should be a simple abstraction (i.e., a small class) that represents the ratio of two numbers. There will be only two data elements, and only a few methods. Note that it is required for your Fraction class to store your ratio in reduced form, so this is feature to implement in your software.

- The numerator –
*what primitive type makes the most sense here?* - The denominator –
*same type as the numerator.*

**Overloading**- Fraction() – default “no-arg” constructor
- Fraction(int,int) – constructor which initializes your data

**Overriding**- boolean equals(Fraction other) – compares “this” to “other”
- String toString() – replace this inherited method with one appropriate to the class

**Getters & Setters**- getNumerator()
- setNumerator(…)
- getDenominator()
- setDenominator(…)

This class should also be small, and contain only a few state variables. The purpose of this class is to store a reference to a Fraction object and a count of how many times this fraction object has been seen in the input file.

- The Fraction – declare this class variable to be of type Fraction from above
- The counter – the integer value used to count the number of these fractions seen

- FractionCounter( Fraction theFraction ) – constructor
- bool compareAndIncrement( Fraction newFraction ) – used to see if the newFraction passed into this function is the same as the Fraction we’re storing, and if so increments the counter by one and returns true (otherwise, returns false).
- String toString() – replace this inherited method with one that prints out both the Fraction and its count

Error handling

- When encountering illegal data, print an error message, skip the data, and continue processing

Before submitting your assignment, be sure to thoroughly test it – for example, if your software fails to compile, the maximum grade falls to a 75%. Does your software reduce fractions? Test this common case. What about boundary cases or unusual situations? For example, does your software read in the fraction “4/0” and crash with a DivideByZeroException? Can your software handle 0 fractions? 1 fraction? 1,000 fractions? What does your software do with the fraction “-1/-4”? What if the numerator or denominator is very large, as in “1/9999”? Does your program report the fraction “1/1 occurs 4 times” only once (as it should, for the fractions.txt file linked in Fractions V1), or does it report “1/1 occurs 4 times” multiple times (which it should not)? If you store the fraction using doubles, does the equals() function suffer from roundoff errors? Test your code for as many cases as you can think of by varying the “fractions.txt” input file. Note that I will try multiple “fractions.txt” input files when grading your assignment.

NB: You **need to code your program it so it can run with input files besides the example one. **In particular, it has to work with input files that are of any length. **You must enable the appropriate lists to dynamically resize.**

Build two classes (**Fraction** and **FractionCounter**) and a **Driver** for use in counting the number of unique fractions read from a text file. We’ll also reuse the **ObjectList** class we built in lab to store our list of unique **FractionCounters, **instead of directly using arrays or the **ArrayList**. Rather than designing a monolithic chunk of code in main like we did in the previous homework, we’ll practice distributing our code into containers (called classes) that you will design specifically to tackle this same problem in a different and more logically organized fashion.

Remember

- NO DECIMALS!
- Handle input of any length

Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in one line at a time and build a **Fraction** object from A and B. For each unique **Fraction** seen, your program will create a **FractionCounter** object used to track the number of occurrences of that specific fraction. When all the input is consumed, your program will print out its **ObjectList** of unique **FractionCounters**, which should report the fraction and its count – see output below. You can assume no blank lines or misleading characters; see the text file link above for the some of the input I’ll use when testing your submission. Your program must reduce fractions, as demonstrated in the output below.

This class should be a simple abstraction (i.e., a small class) that represents the ratio of two numbers. There will be only two data elements, and only a few methods. Note that it is required for your Fraction class to store your ratio in reduced form, so this is feature to implement in your software.

- The numerator –
*what primitive type makes the most sense here?* - The denominator –
*same type as the numerator.*

**Overloading**- Fraction() – default “no-arg” constructor
- Fraction(int,int) – constructor which initializes your data

**Overriding**- boolean equals(Fraction other) – compares “this” to “other”
- String toString() – replace this inherited method with one appropriate to the class

**Getters & Setters**- getNumerator()
- setNumerator(…)
- getDenominator()
- setDenominator(…)

This class should also be small, and contain only a few state variables. The purpose of this class is to store a reference to a Fraction object and a count of how many times this fraction object has been seen in the input file.

- The Fraction – declare this class variable to be of type Fraction from above
- The counter – the integer value used to count the number of these fractions seen

- FractionCounter( Fraction theFraction ) – constructor
- bool compareAndIncrement( Fraction newFraction ) – used to see if the newFraction passed into this function is the same as the Fraction we’re storing, and if so increments the counter by one and returns true (otherwise, returns false).
- String toString() – replace this inherited method with one that prints out both the Fraction and its count

Error handling

- When encountering illegal data, print an error message, skip the data, and continue processing

The price is based on these factors:

Academic level

Number of pages

Urgency

Basic features

- Free title page and bibliography
- Unlimited revisions
- Plagiarism-free guarantee
- Money-back guarantee
- 24/7 support

On-demand options

- Writer’s samples
- Part-by-part delivery
- Overnight delivery
- Copies of used sources
- Expert Proofreading

Paper format

- 275 words per page
- 12 pt Arial/Times New Roman
- Double line spacing
- Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Delivering a high-quality product at a reasonable price is not enough anymore.

That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
## Recent Comments