Skip to content

ucsb-cs56-pconrad/cs56-rational-ex03

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is part of a series of Java tutorials for a Rational class written by Phill Conrad for CMPSC 56, a Java course taught in the Dept. of Computer Science at UC Santa Barbara.

For detailed instructions, see:

Previous Repo This Repo Next Repo
cs56-rational-ex02 cs56-rational-ex03 cs56-rational-ex04
Previous Lesson This Lesson Next Lesson
rational_ex02 rational_ex03 rational_ex04

Quick start

Once you clone this repo, these commands show how to compile and run the code inside. You need ant to following these instructions; refer to cs56-rational-ex02 and the article on ant for more information.

The build.xml file in this repo is set up to produce a jar file:

To run this new target, we use:

ex03 pconrad$ ant jar
Buildfile: /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03/build.xml

compile:
    [javac] Compiling 2 source files to /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03

jar:
      [jar] Building jar: /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03/build/rational.jar

BUILD SUCCESSFUL
Total time: 0 seconds
ex03 pconrad$ 

We can then run the file with this command:

ex03 pconrad$ java -jar build/rational.jar 
r.getNumerator()=5
r.getDenominator()=7
ex03 pconrad$ 

To compile:

ex03 pconrad$ ant compile
Buildfile: /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03/build.xml

compile:
    [javac] Compiling 3 source files to /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03

BUILD SUCCESSFUL
Total time: 0 seconds
ex03 pconrad$ 

To run the JUnit tests in the repo:

ex03 pconrad$ ant test
Buildfile: /Users/pconrad/github/UCSB-CS56-M16/cs56-rational-example/ex03/build.xml

compile:

test:
    [junit] Testsuite: RationalTest
    [junit] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.059 sec
    [junit]

BUILD SUCCESSFUL
Total time: 0 seconds
ex03 pconrad$