Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Goals - To write your own class in a program. - To write a constructor with parameters, an method and a toString0 method. -

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1 Goals - To write your own class in a program. - To write a constructor with parameters, an method and a toString0 method. - To use ArrayList. - To use a for-each loop. - To use text file for output 2 The Context This is a single-class project, the first for which I have not given you code to start from. It is not realistic, or useful, but it gives us a place to start. This does not follow the MVC pattern for simplicity's sake. It is very important that you follow these instructions closely. They will guide you through learning a specific set of skills. Do not try to solve the problem some other way. 2.1 The Olympian Class Create a class called "Olympian" to hold the facts about a member of the 2018 USA Olympic Team: name, sport, numMedals and event. 1. In this class, provide four private data members: name, sport, numMedals and event. 2. Create a constructor with four parameters (name, sport, numMedals and event). 3. Also provide a toString0 method and a computeMedals 0 method. The compute function. In your computeMedals ), a static function, do all of the following: 1. Take one parameter, an array of Olympian objects. 2. Use a for-each loop to walk through the ArrayList. 3. For each Olympian in the array: get the numMedals using an accessor method (getter). use the numMedals to add to the total number of medals for all the Olympians return the total number of medals. The main function. In your main function, do all of the following: 4. Output a welcome message to the console that includes the assignment name, P3: Olympians and your name. 5. Allocate an ArrayList of the class Olympian. 6. In a loop, read in the name, sport, numMedals and event of each Olympian. Use these to create an Olympian object and add it to the Olympians ArrayList. Validate input for NumMedals. It cannot be negative or more than 10 (Michael Phelps has 8 ) but it can be zero. 7. When input is finished, call the function named computeMedals 0 , described above, and receive a return value that is the total medals received by all the Olympians in your list. Print this to the console with an appropriate label. 8. Use a for-each loop to print the array of Olympians and show their name, sport, numMedals and event. Use proper labels and spacing so it looks like a table. 9. Open a file named "results.txt" for output and declare a PrintWriter. Use a for-each loop to print the array of Olympians into the file and show their name. sport, numMedals and event. Program 3: Olympians Make the columns line up by formatting the output. You may want a printRow0 function for this. Put a line of ' = ' at the bottom of the numMedals column, then show the total number of medals. Don't forget to close your PrintWriter. Optional challenges: 11. Use MVC pattern and use multiple classes. 12. Keep track of Gold, Silver and Bronze medals separately. Show sum by medal type and total of all medals at the bottom of the console output and the file output. 13. Read data from an input file that contains the data you cut and pasted from the https:/len.wikipedia.org/wiki/United States at the 2018 Winter Olympics . - Read the data into the ArravList (note how will you handle team events?) 3 Testing, Documentation, and Submission. - Use the Eclipse Project menu Generate Javadoc option, to run the Javadoc application. Tell Javadoc to put your documentation in the project folder. It generates a lot of files (.html). Open the Javadoc and take a screen shot or print to a .pdf of the Olympians class page. Hand in this screen shot/.pdf, not the entire Javadoc html. - Run your program using several test cases (enough to test all parts of the program). Copy the output and put it all into one file. Label each test clearly with a clear description. Add your own test cases to the end. For no Olympians, the program must still end gracefully. For example: Label the test 1 like this: H1111111111111+ Test 1 - Zero Olympians +1111111+ Test the program at least three times, 1. Test one with a no Olympians, 2. Test two with 1 Olympian, 3. Test three with at least 10 or more Olympians. - Create a folder named P3.>.sec\# Put the source code (.java) file into the directory. Add the screen shot/pdf of your Javadoc class page for Olympians. Add the output txt with the console output from all the tests clearly labeled. Then compress the folder, the zip should be automatically added to the folder name. Email your zipped folder to me at profpageUNH@gmail.com with 'P3 Olympians' as the subject line. CAUTION: Do not include class or html files or other executable files, it will cause your work to be rejected by gmail or the UNH email or both. You do not get an error message for this failure. Assignments Details Discussions P3 Olympians.docx People 1 Goals Grades 1 - To write your own class in a program. - To write a constructor with parameters, an method and a toString() method. StudyMate - To use Arraylist. Media Gallery - To use a for-each loop. - To use text file for output My Media 2 The Context Badges This is a single-class project, the first for which I have not given you code to start from. It is not realistic, or useful, but it gives us a place to start. Thi Course Ratings follow the MVC pattern for simplicity's sake. It is very important that you follow these instructions closely. They will guide you through leaming a spe Zoom of skills. Do not try to solve the problem some other way. Quizzes - The Olympian Class Create a class called "Olympian" to hold the facts about a member of the 2018 USA Olympic Team: name, sport, numMedals and event. ue: Mon, 27 Feb 2023 23:50 IN PROGRESS Next Up: Submit assignment 1. In this class, provide four private data members: name, sport, numMedals and event. 2. Create a constructor with four parameters (name, sport, numMedals and event). 3. Also provide a toString() method and a computeMedals() method. The compute function. In your computeMedals(), a static function, do all of the following: 1. Take one parameter, an array of Olympian objects. 2. Use a for-each loop to walk through the ArrayList. 3. For each Olympian in the array: get the numMedals using an accessor method (getter). use the numMedals to add to the total number of medals for all the Olympians - return the total number of medals. The main function. In your main function, do all of the following: 4. Output a welcome message to the console that includes the assignment name, P3: Olympians and your name. 5. Allocate an ArrayList of the class Olympian. 6. In a loop, read in the name, sport, numMedals and event of each Olympian. Use these to create an Olympian object and add it to the Olympian - Validate input for NumMedals. It cannot be negative or more than 10 (Michael Phelps has 8 ) but it can be zero. 7. When input is finished, call the function named computeMedals(), described above, and receive a return value that is the total medals received Olympians in your list. Print this to the console with an appropriate label. 8. Use a for-each loop to print the array of Olympians and show their name, sport, numMedals and event. Use proper labels and spacing so it looks 9. Open a file named "results.txt" for output and declare a PrintWriter. - Use a for-each loop to print the array of Olympians into the file and show their name, sport, numMedals and event. - Make the columns line up by formatting the output. You may want a printRow() function for this. - Put a line of ' =' at the bottom of the numMedals column, then show the total number of medals. - Don't forget to close your PrintWriter. 10. Print a departing message thanking your user. Optional challenges: 11. Use MVC pattern and use multiple classes. 12. Keep track of Gold, Silver and Bronze medals separately. Show sum by medal type and total of all medals at the bottom of the console output and the file output. 13. Read data from an input file that contains the data you cut and pasted from the https://en.wikipedia.org/wiki/United States at the 2018 Winter Olympics 3. - Read the data into the ArrayList (note how will you handle team events?) Medal Name Sport Event Date Gold Redmond Gerard Snowboarding G Men's slopestyle G February 11 - Use the Eclipse Project menu Generate Javadoc option, to run the Javadoc application. Tell Javadoc to put your documentation in the project folder. It generates a lot of files (.html). Open the Javadoc and take a screen shot or print to a .pdf of the Olympians class page. Hand in this screen shot/.pdf, not the entire Javadoc html. - Run your program using several test cases (enough to test all parts of the program). Copy the output and put it all into one file. Label each test clearly with a clear description. Add your own test cases to the end. For no Olympians, the program must still end gracefully. For example: Label the test 1 like this: +++++++++++++++ Test 1 - Zero Olympians ++++++++++ Test the program at least three times, 1. Test one with a no Olympians, 2. Test two with 1 Olympian, 3. Test three with at least 10 or more Olympians. - Create a folder named >.sec\# - Put the source code (.java) file into the directory. - Add the screen shot/.pdf of your Javadoc class page for Olympians. - Add the output.txt with the console output from all the tests clearly labeled. - Then compress the folder, the .zip should be automatically added to the folder name

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago