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

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, spoit, numMedals and event). 3. Also provide a toString() method and a computeMedals() method. The compute function. In your computeMedals 0 , 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 ArrayL ist. 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 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. numiledals and event. 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. 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 hittps: Wen wikipedia org wiki United States at the 2018-Winter-Olympics 1 Gold Chloe Kim Snowboarding Women's halfpipe February 13 1 Gold Shaun White Snowboarding Men's halfpipe February 14 2. Silver Chris Mazdzer Luge Men's singles February 11 Nathan Chen Alexa Scimeca Knierim Chris Knierim (3) Bronze Mirai Nagasu Figure skating Team event February 12 Alex Shibutan: Maia Shibutani Bradie Tennell 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 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: +1+1+11+11+1++ Test 1 Zero Olympians +111+1+1+ 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. - To write your own class in a program. - To write a constructor with parameters, an method and a toString() 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 star follow the MVC pattern for simplicity's sake. It is very important that you follow these instructions closely. They will guide you through learning of skills. Do not try to solve the problem some other way. - 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 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. 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(), 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. - 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. Next Up: Submit Assignment 7. When input is finished, call the function named computeMedals(), described above, and receive a return value that is the total medals receive 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 loc 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. - 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 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 G : - Read the data into the Array List (note how will you handle team events?) Medal Name Sport Event Date Spring 2023 Programming Assignment; P3 Olympians - Part 1 not sorted Due: Mon Feb 20, 2023 12:30pm Home Attempt 1 IN PROGRESS Announcements Next Up: Submit Assignment 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: t+++++++++++++++ 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 YourName >. 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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Explain the role and the importance of L&D in an organisation.

Answered: 1 week ago

Question

A basic principle of persuasion is:

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago