Browse Source

added files

master
school 7 years ago
parent
commit
6412af193a
  1. 9
      files/IAthlete.java
  2. 9
      files/ITrainer.java
  3. 38
      files/MathProblems.java
  4. 14
      files/SkiJumper.java
  5. 30
      files/StockPrices.java
  6. 28
      files/TestSkiJumper.java
  7. 6
      files/portfolio.txt

9
files/IAthlete.java

@ -0,0 +1,9 @@
/* Interface IAthlete.java
* CS207-2 Homework 7 Fall 2018
* An interface is a behavior that implementing classes are required to conform to.
* Do not make changes to this class.
*/
public interface IAthlete
{
public abstract void data();
}

9
files/ITrainer.java

@ -0,0 +1,9 @@
/* Interface ITrainer.java
* CS207-2 Homework 7 Fall 2018
* An interface is a behavior that implementing classes are required to conform to.
* Do not make changes to this class.
*/
public interface ITrainer
{
public abstract void train( double h );
}

38
files/MathProblems.java

@ -0,0 +1,38 @@
import java.util.*;
public class MathProblems
{
// Implement this method, which prompts the user for a and b, then divides a by b
// and then calculates a % b. If the user enters an invalid type of input, or a
// zero for the divisor, an Exception will be thrown, both of which need to be caught
public void divide()
{
try
{
}
catch( )
{
}
catch( )
{
}
}
public static void main( String[] args )
{
// Test it here in main, when ready
MathFunctions functions = new MathFunctions();
functions.divide();
}
}

14
files/SkiJumper.java

@ -0,0 +1,14 @@
/* SkiJumper.java
* CS207-2 Homework 7 Fall 2018
* This class represents a Ski Jumper in code.
*
* Add code to this class by implementing the interfaces
* ITrainer and IAthlete such that the code in main()
* executes providing the output shown in Problem 3.
*/
public class SkiJumper implements IAthlete, ITrainer
{
} // End class SkiJumper

30
files/StockPrices.java

@ -0,0 +1,30 @@
import java.util.*;
import java.io.*;
public class StockPrices
{
public static void main( String[] args )
{
double total = 0.0;
Scanner inputFile = null;
// Use a loop in the try block to read each line of the file.
// Lecture Slides 13 (posted on D2L) provide a good example
try
{
}
catch( )
{
// A FileNotFoundException needs to be handled here
}
finally
{
}
System.out.println( "The total value is: $" + total );
}
}

28
files/TestSkiJumper.java

@ -0,0 +1,28 @@
/* TestSkiJumper.java
* CS207-2 Homework 7 Fall 2018
* This class has main() and tests the implementation of SkiJumper.java.
* Do not make changes to this class.
*/
public class TestSkiJumper
{
public static void main( String[] args )
{
// Create a new Ski Jumper
SkiJumper sk1 = new SkiJumper( "John Smith" );
sk1.train(5.2);
sk1.jump();
sk1.train(3.2);
sk1.jump();
sk1.data();
// Create another new Ski Jumper
SkiJumper sk2 = new SkiJumper( "Jenny Adam" );
sk2.train(7.3);
sk2.jump();
sk2.data();
System.out.println(sk2.equals(sk1));
sk2.jump();
System.out.println(sk2.equals(sk1));
}
}

6
files/portfolio.txt

@ -0,0 +1,6 @@
Microsoft 31.63
Intel 88.54
Facebook 0.13
Twitter 56.23
Oracle 77.01
Canonical 45.97
Loading…
Cancel
Save