Question: Must Do: Placing all code in one file Please place all classes into one Java file. I request this to make my life easier when
Must Do: Placing all code in one file
Please place all classes into one Java file.
I request this to make my life easier when helping students and to make the graders life easier.
In industry the practice is to place each class into its own file, but here we will use only one file.
To place all code into one file, the layout should be as follows:
public class Assignment
public static void mainString args throws IOException
Code to read file and create skies and place into array
main
Assignment Note this is the end of your assignment
New classes go AFTER this point
New classes do not include public keyword
class Ski
Details for the ski class go here
Ski
class CrossCountry extends Ski
Details for the cross country ski class go here
CrossCountry
Add remaining classes here
Tip: Build the classes first
Before writing the code in main, build as many of the details in the classes as possible.
Create at least a skeleton of each class before writing the code in main to create the skis.
If you dont yet know what code belongs in a method, stub the method out ie write an empty
method If a return value is expected, return a temporary value to keep code error free.
Tip: Reading from files
When reading from a file, use the methods in the Scanner class to obtain the different pieces of
data in the file.
DO NOT read one entire line and then parse the line to get the different values.
o This means do not use Integer.parseInt method
Use the Scanner methods next nextDouble nextInt etc. to do the parsing for you.
If you need a review of the Scanner methods next and nextLine, see Lecture #String Review
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
