initial setup

This commit is contained in:
Jaanus Poeial 2016-09-22 12:39:36 +03:00
commit f3009d068e
27 changed files with 3879 additions and 0 deletions

605
Lfraction/Lfraction.html Normal file
View File

@ -0,0 +1,605 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Lfraction</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Lfraction";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="index.html?Lfraction.html" target="_top">Frames</a></li>
<li><a href="Lfraction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<h2 title="Class Lfraction" class="title">Class Lfraction</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>Lfraction</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.lang.Comparable&lt;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&gt;</dd>
</dl>
<hr>
<br>
<pre>public class <span class="strong">Lfraction</span>
extends java.lang.Object
implements java.lang.Comparable&lt;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&gt;</pre>
<div class="block">This class presents fractions of form n/d where n and d are long integer
numbers. Basic operations and arithmetics for fractions are provided.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="Lfraction.html#Lfraction(long, long)">Lfraction</a></strong>(long&nbsp;a,
long&nbsp;b)</code>
<div class="block">Constructor.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#clone()">clone</a></strong>()</code>
<div class="block">Clone of the fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#compareTo(Lfraction)">compareTo</a></strong>(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</code>
<div class="block">Comparision of fractions.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#divideBy(Lfraction)">divideBy</a></strong>(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</code>
<div class="block">Quotient of fractions.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#equals(java.lang.Object)">equals</a></strong>(java.lang.Object&nbsp;m)</code>
<div class="block">Equality test.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#fractionPart()">fractionPart</a></strong>()</code>
<div class="block">Extract fraction part of the (improper) fraction
(a proper fraction without the integer part).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#getDenominator()">getDenominator</a></strong>()</code>
<div class="block">Public method to access the denominator field.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#getNumerator()">getNumerator</a></strong>()</code>
<div class="block">Public method to access the numerator field.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#hashCode()">hashCode</a></strong>()</code>
<div class="block">Hashcode has to be equal for equal fractions.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#integerPart()">integerPart</a></strong>()</code>
<div class="block">Integer part of the (improper) fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#inverse()">inverse</a></strong>()</code>
<div class="block">Inverse of the fraction.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#main(java.lang.String[])">main</a></strong>(java.lang.String[]&nbsp;param)</code>
<div class="block">Main method.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#minus(Lfraction)">minus</a></strong>(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</code>
<div class="block">Difference of fractions.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#opposite()">opposite</a></strong>()</code>
<div class="block">Opposite of the fraction.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#plus(Lfraction)">plus</a></strong>(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</code>
<div class="block">Sum of fractions.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#times(Lfraction)">times</a></strong>(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</code>
<div class="block">Multiplication of fractions.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#toDouble()">toDouble</a></strong>()</code>
<div class="block">Approximate value of the fraction.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#toLfraction(double, long)">toLfraction</a></strong>(double&nbsp;f,
long&nbsp;d)</code>
<div class="block">Double value f presented as a fraction with denominator d > 0.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#toString()">toString</a></strong>()</code>
<div class="block">Conversion to string.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></code></td>
<td class="colLast"><code><strong><a href="Lfraction.html#valueOf(java.lang.String)">valueOf</a></strong>(java.lang.String&nbsp;s)</code>
<div class="block">Conversion from string to the fraction.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>finalize, getClass, notify, notifyAll, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="Lfraction(long, long)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Lfraction</h4>
<pre>public&nbsp;Lfraction(long&nbsp;a,
long&nbsp;b)</pre>
<div class="block">Constructor.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - numerator</dd><dd><code>b</code> - denominator > 0</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="main(java.lang.String[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>main</h4>
<pre>public static&nbsp;void&nbsp;main(java.lang.String[]&nbsp;param)</pre>
<div class="block">Main method. Different tests.</div>
</li>
</ul>
<a name="getNumerator()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getNumerator</h4>
<pre>public&nbsp;long&nbsp;getNumerator()</pre>
<div class="block">Public method to access the numerator field.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>numerator</dd></dl>
</li>
</ul>
<a name="getDenominator()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDenominator</h4>
<pre>public&nbsp;long&nbsp;getDenominator()</pre>
<div class="block">Public method to access the denominator field.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>denominator</dd></dl>
</li>
</ul>
<a name="toString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre>public&nbsp;java.lang.String&nbsp;toString()</pre>
<div class="block">Conversion to string.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>string representation of the fraction</dd></dl>
</li>
</ul>
<a name="equals(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public&nbsp;boolean&nbsp;equals(java.lang.Object&nbsp;m)</pre>
<div class="block">Equality test.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>equals</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - second fraction</dd>
<dt><span class="strong">Returns:</span></dt><dd>true if fractions this and m are equal</dd></dl>
</li>
</ul>
<a name="hashCode()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hashCode</h4>
<pre>public&nbsp;int&nbsp;hashCode()</pre>
<div class="block">Hashcode has to be equal for equal fractions.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>hashCode</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>hashcode</dd></dl>
</li>
</ul>
<a name="plus(Lfraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>plus</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;plus(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</pre>
<div class="block">Sum of fractions.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - second addend</dd>
<dt><span class="strong">Returns:</span></dt><dd>this+m</dd></dl>
</li>
</ul>
<a name="times(Lfraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>times</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;times(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</pre>
<div class="block">Multiplication of fractions.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - second factor</dd>
<dt><span class="strong">Returns:</span></dt><dd>this*m</dd></dl>
</li>
</ul>
<a name="inverse()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>inverse</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;inverse()</pre>
<div class="block">Inverse of the fraction. n/d becomes d/n.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>inverse of this fraction: 1/this</dd></dl>
</li>
</ul>
<a name="opposite()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>opposite</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;opposite()</pre>
<div class="block">Opposite of the fraction. n/d becomes -n/d.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>opposite of this fraction: -this</dd></dl>
</li>
</ul>
<a name="minus(Lfraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>minus</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;minus(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</pre>
<div class="block">Difference of fractions.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - subtrahend</dd>
<dt><span class="strong">Returns:</span></dt><dd>this-m</dd></dl>
</li>
</ul>
<a name="divideBy(Lfraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>divideBy</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;divideBy(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</pre>
<div class="block">Quotient of fractions.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - divisor</dd>
<dt><span class="strong">Returns:</span></dt><dd>this/m</dd></dl>
</li>
</ul>
<a name="compareTo(Lfraction)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareTo</h4>
<pre>public&nbsp;int&nbsp;compareTo(<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;m)</pre>
<div class="block">Comparision of fractions.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code>compareTo</code>&nbsp;in interface&nbsp;<code>java.lang.Comparable&lt;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&gt;</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>m</code> - second fraction</dd>
<dt><span class="strong">Returns:</span></dt><dd>-1 if this < m; 0 if this==m; 1 if this > m</dd></dl>
</li>
</ul>
<a name="clone()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clone</h4>
<pre>public&nbsp;java.lang.Object&nbsp;clone()
throws java.lang.CloneNotSupportedException</pre>
<div class="block">Clone of the fraction.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>clone</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>new fraction equal to this</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.CloneNotSupportedException</code></dd></dl>
</li>
</ul>
<a name="integerPart()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>integerPart</h4>
<pre>public&nbsp;long&nbsp;integerPart()</pre>
<div class="block">Integer part of the (improper) fraction.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>integer part of this fraction</dd></dl>
</li>
</ul>
<a name="fractionPart()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fractionPart</h4>
<pre>public&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;fractionPart()</pre>
<div class="block">Extract fraction part of the (improper) fraction
(a proper fraction without the integer part).</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>fraction part of this fraction</dd></dl>
</li>
</ul>
<a name="toDouble()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDouble</h4>
<pre>public&nbsp;double&nbsp;toDouble()</pre>
<div class="block">Approximate value of the fraction.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>numeric value of this fraction</dd></dl>
</li>
</ul>
<a name="toLfraction(double, long)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toLfraction</h4>
<pre>public static&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;toLfraction(double&nbsp;f,
long&nbsp;d)</pre>
<div class="block">Double value f presented as a fraction with denominator d > 0.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - real number</dd><dd><code>d</code> - positive denominator for the result</dd>
<dt><span class="strong">Returns:</span></dt><dd>f as an approximate fraction of form n/d</dd></dl>
</li>
</ul>
<a name="valueOf(java.lang.String)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>valueOf</h4>
<pre>public static&nbsp;<a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a>&nbsp;valueOf(java.lang.String&nbsp;s)</pre>
<div class="block">Conversion from string to the fraction. Accepts strings of form
that is defined by the toString method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>s</code> - string form (as produced by toString) of the fraction</dd>
<dt><span class="strong">Returns:</span></dt><dd>fraction represented by s</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="index.html?Lfraction.html" target="_top">Frames</a></li>
<li><a href="Lfraction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

164
Lfraction/Lfraction.java Normal file
View File

@ -0,0 +1,164 @@
import java.util.*;
/** This class presents fractions of form n/d where n and d are long integer
* numbers. Basic operations and arithmetics for fractions are provided.
*/
public class Lfraction implements Comparable<Lfraction> {
/** Main method. Different tests. */
public static void main (String[] param) {
// TODO!!! Your debugging tests here
}
// TODO!!! instance variables here
/** Constructor.
* @param a numerator
* @param b denominator > 0
*/
public Lfraction (long a, long b) {
// TODO!!!
}
/** Public method to access the numerator field.
* @return numerator
*/
public long getNumerator() {
return 0L; // TODO!!!
}
/** Public method to access the denominator field.
* @return denominator
*/
public long getDenominator() {
return 1L; // TODO!!!
}
/** Conversion to string.
* @return string representation of the fraction
*/
@Override
public String toString() {
return ""; // TODO!!!
}
/** Equality test.
* @param m second fraction
* @return true if fractions this and m are equal
*/
@Override
public boolean equals (Object m) {
return false; // TODO!!!
}
/** Hashcode has to be equal for equal fractions.
* @return hashcode
*/
@Override
public int hashCode() {
return 0; // TODO!!!
}
/** Sum of fractions.
* @param m second addend
* @return this+m
*/
public Lfraction plus (Lfraction m) {
return null; // TODO!!!
}
/** Multiplication of fractions.
* @param m second factor
* @return this*m
*/
public Lfraction times (Lfraction m) {
return null; // TODO!!!
}
/** Inverse of the fraction. n/d becomes d/n.
* @return inverse of this fraction: 1/this
*/
public Lfraction inverse() {
return null; // TODO!!!
}
/** Opposite of the fraction. n/d becomes -n/d.
* @return opposite of this fraction: -this
*/
public Lfraction opposite() {
return null; // TODO!!!
}
/** Difference of fractions.
* @param m subtrahend
* @return this-m
*/
public Lfraction minus (Lfraction m) {
return null; // TODO!!!
}
/** Quotient of fractions.
* @param m divisor
* @return this/m
*/
public Lfraction divideBy (Lfraction m) {
return null; // TODO!!!
}
/** Comparision of fractions.
* @param m second fraction
* @return -1 if this < m; 0 if this==m; 1 if this > m
*/
public int compareTo (Lfraction m) {
return 0; // TODO!!!
}
/** Clone of the fraction.
* @return new fraction equal to this
*/
@Override
public Object clone() throws CloneNotSupportedException {
return null; // TODO!!!
}
/** Integer part of the (improper) fraction.
* @return integer part of this fraction
*/
public long integerPart() {
return 0L; // TODO!!!
}
/** Extract fraction part of the (improper) fraction
* (a proper fraction without the integer part).
* @return fraction part of this fraction
*/
public Lfraction fractionPart() {
return null; // TODO!!!
}
/** Approximate value of the fraction.
* @return numeric value of this fraction
*/
public double toDouble() {
return 0.; // TODO!!!
}
/** Double value f presented as a fraction with denominator d > 0.
* @param f real number
* @param d positive denominator for the result
* @return f as an approximate fraction of form n/d
*/
public static Lfraction toLfraction (double f, long d) {
return null; // TODO!!!
}
/** Conversion from string to the fraction. Accepts strings of form
* that is defined by the toString method.
* @param s string form (as produced by toString) of the fraction
* @return fraction represented by s
*/
public static Lfraction valueOf (String s) {
return null; // TODO!!!
}
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>All Classes</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<h1 class="bar">All Classes</h1>
<div class="indexContainer">
<ul>
<li><a href="Lfraction.html" title="class in &lt;Unnamed&gt;" target="classFrame">Lfraction</a></li>
</ul>
</div>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>All Classes</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<h1 class="bar">All Classes</h1>
<div class="indexContainer">
<ul>
<li><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></li>
</ul>
</div>
</body>
</html>

View File

@ -0,0 +1,112 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Constant Field Values</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Constant Field Values";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?constant-values.html" target="_top">Frames</a></li>
<li><a href="constant-values.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Constant Field Values" class="title">Constant Field Values</h1>
<h2 title="Contents">Contents</h2>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?constant-values.html" target="_top">Frames</a></li>
<li><a href="constant-values.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

View File

@ -0,0 +1,112 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Deprecated List</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Deprecated List";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li class="navBarCell1Rev">Deprecated</li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?deprecated-list.html" target="_top">Frames</a></li>
<li><a href="deprecated-list.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Deprecated API" class="title">Deprecated API</h1>
<h2 title="Contents">Contents</h2>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li class="navBarCell1Rev">Deprecated</li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?deprecated-list.html" target="_top">Frames</a></li>
<li><a href="deprecated-list.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

209
Lfraction/help-doc.html Normal file
View File

@ -0,0 +1,209 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>API Help</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="API Help";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li class="navBarCell1Rev">Help</li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?help-doc.html" target="_top">Frames</a></li>
<li><a href="help-doc.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">How This API Document Is Organized</h1>
<div class="subTitle">This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.</div>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<h2>Package</h2>
<p>Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:</p>
<ul>
<li>Interfaces (italic)</li>
<li>Classes</li>
<li>Enums</li>
<li>Exceptions</li>
<li>Errors</li>
<li>Annotation Types</li>
</ul>
</li>
<li class="blockList">
<h2>Class/Interface</h2>
<p>Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:</p>
<ul>
<li>Class inheritance diagram</li>
<li>Direct Subclasses</li>
<li>All Known Subinterfaces</li>
<li>All Known Implementing Classes</li>
<li>Class/interface declaration</li>
<li>Class/interface description</li>
</ul>
<ul>
<li>Nested Class Summary</li>
<li>Field Summary</li>
<li>Constructor Summary</li>
<li>Method Summary</li>
</ul>
<ul>
<li>Field Detail</li>
<li>Constructor Detail</li>
<li>Method Detail</li>
</ul>
<p>Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</p>
</li>
<li class="blockList">
<h2>Annotation Type</h2>
<p>Each annotation type has its own separate page with the following sections:</p>
<ul>
<li>Annotation Type declaration</li>
<li>Annotation Type description</li>
<li>Required Element Summary</li>
<li>Optional Element Summary</li>
<li>Element Detail</li>
</ul>
</li>
<li class="blockList">
<h2>Enum</h2>
<p>Each enum has its own separate page with the following sections:</p>
<ul>
<li>Enum declaration</li>
<li>Enum description</li>
<li>Enum Constant Summary</li>
<li>Enum Constant Detail</li>
</ul>
</li>
<li class="blockList">
<h2>Tree (Class Hierarchy)</h2>
<p>There is a <a href="overview-tree.html">Class Hierarchy</a> page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.</p>
<ul>
<li>When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.</li>
<li>When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.</li>
</ul>
</li>
<li class="blockList">
<h2>Deprecated API</h2>
<p>The <a href="deprecated-list.html">Deprecated API</a> page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.</p>
</li>
<li class="blockList">
<h2>Index</h2>
<p>The <a href="index-all.html">Index</a> contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.</p>
</li>
<li class="blockList">
<h2>Prev/Next</h2>
<p>These links take you to the next or previous class, interface, package, or related page.</p>
</li>
<li class="blockList">
<h2>Frames/No Frames</h2>
<p>These links show and hide the HTML frames. All pages are available with or without frames.</p>
</li>
<li class="blockList">
<h2>All Classes</h2>
<p>The <a href="allclasses-noframe.html">All Classes</a> link shows all classes and interfaces except non-static nested types.</p>
</li>
<li class="blockList">
<h2>Serialized Form</h2>
<p>Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.</p>
</li>
<li class="blockList">
<h2>Constant Field Values</h2>
<p>The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.</p>
</li>
</ul>
<em>This help file applies to API documentation generated using the standard doclet.</em></div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li class="navBarCell1Rev">Help</li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?help-doc.html" target="_top">Frames</a></li>
<li><a href="help-doc.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

273
Lfraction/index-all.html Normal file
View File

@ -0,0 +1,273 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Index</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="./stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Index";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="./package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="./overview-tree.html">Tree</a></li>
<li><a href="./deprecated-list.html">Deprecated</a></li>
<li class="navBarCell1Rev">Index</li>
<li><a href="./help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="./index.html?index-all.html" target="_top">Frames</a></li>
<li><a href="index-all.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="./allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="contentContainer"><a href="#_C_">C</a>&nbsp;<a href="#_D_">D</a>&nbsp;<a href="#_E_">E</a>&nbsp;<a href="#_F_">F</a>&nbsp;<a href="#_G_">G</a>&nbsp;<a href="#_H_">H</a>&nbsp;<a href="#_I_">I</a>&nbsp;<a href="#_L_">L</a>&nbsp;<a href="#_M_">M</a>&nbsp;<a href="#_O_">O</a>&nbsp;<a href="#_P_">P</a>&nbsp;<a href="#_T_">T</a>&nbsp;<a href="#_V_">V</a>&nbsp;<a name="_C_">
<!-- -->
</a>
<h2 class="title">C</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#clone()">clone()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Clone of the fraction.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#compareTo(Lfraction)">compareTo(Lfraction)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Comparision of fractions.</div>
</dd>
</dl>
<a name="_D_">
<!-- -->
</a>
<h2 class="title">D</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#divideBy(Lfraction)">divideBy(Lfraction)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Quotient of fractions.</div>
</dd>
</dl>
<a name="_E_">
<!-- -->
</a>
<h2 class="title">E</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#equals(java.lang.Object)">equals(Object)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Equality test.</div>
</dd>
</dl>
<a name="_F_">
<!-- -->
</a>
<h2 class="title">F</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#fractionPart()">fractionPart()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Extract fraction part of the (improper) fraction
(a proper fraction without the integer part).</div>
</dd>
</dl>
<a name="_G_">
<!-- -->
</a>
<h2 class="title">G</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#getDenominator()">getDenominator()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Public method to access the denominator field.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#getNumerator()">getNumerator()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Public method to access the numerator field.</div>
</dd>
</dl>
<a name="_H_">
<!-- -->
</a>
<h2 class="title">H</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#hashCode()">hashCode()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Hashcode has to be equal for equal fractions.</div>
</dd>
</dl>
<a name="_I_">
<!-- -->
</a>
<h2 class="title">I</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#integerPart()">integerPart()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Integer part of the (improper) fraction.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#inverse()">inverse()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Inverse of the fraction.</div>
</dd>
</dl>
<a name="_L_">
<!-- -->
</a>
<h2 class="title">L</h2>
<dl>
<dt><a href="./Lfraction.html" title="class in &lt;Unnamed&gt;"><span class="strong">Lfraction</span></a> - Class in <a href="./package-summary.html">&lt;Unnamed&gt;</a></dt>
<dd>
<div class="block">This class presents fractions of form n/d where n and d are long integer
numbers.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#Lfraction(long, long)">Lfraction(long, long)</a></span> - Constructor for class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Constructor.</div>
</dd>
</dl>
<a name="_M_">
<!-- -->
</a>
<h2 class="title">M</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#main(java.lang.String[])">main(String[])</a></span> - Static method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Main method.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#minus(Lfraction)">minus(Lfraction)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Difference of fractions.</div>
</dd>
</dl>
<a name="_O_">
<!-- -->
</a>
<h2 class="title">O</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#opposite()">opposite()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Opposite of the fraction.</div>
</dd>
</dl>
<a name="_P_">
<!-- -->
</a>
<h2 class="title">P</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#plus(Lfraction)">plus(Lfraction)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Sum of fractions.</div>
</dd>
</dl>
<a name="_T_">
<!-- -->
</a>
<h2 class="title">T</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#times(Lfraction)">times(Lfraction)</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Multiplication of fractions.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#toDouble()">toDouble()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Approximate value of the fraction.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#toLfraction(double, long)">toLfraction(double, long)</a></span> - Static method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Double value f presented as a fraction with denominator d > 0.</div>
</dd>
<dt><span class="strong"><a href="./Lfraction.html#toString()">toString()</a></span> - Method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Conversion to string.</div>
</dd>
</dl>
<a name="_V_">
<!-- -->
</a>
<h2 class="title">V</h2>
<dl>
<dt><span class="strong"><a href="./Lfraction.html#valueOf(java.lang.String)">valueOf(String)</a></span> - Static method in class <a href="./Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></dt>
<dd>
<div class="block">Conversion from string to the fraction.</div>
</dd>
</dl>
<a href="#_C_">C</a>&nbsp;<a href="#_D_">D</a>&nbsp;<a href="#_E_">E</a>&nbsp;<a href="#_F_">F</a>&nbsp;<a href="#_G_">G</a>&nbsp;<a href="#_H_">H</a>&nbsp;<a href="#_I_">I</a>&nbsp;<a href="#_L_">L</a>&nbsp;<a href="#_M_">M</a>&nbsp;<a href="#_O_">O</a>&nbsp;<a href="#_P_">P</a>&nbsp;<a href="#_T_">T</a>&nbsp;<a href="#_V_">V</a>&nbsp;</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="./package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="./overview-tree.html">Tree</a></li>
<li><a href="./deprecated-list.html">Deprecated</a></li>
<li class="navBarCell1Rev">Index</li>
<li><a href="./help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="./index.html?index-all.html" target="_top">Frames</a></li>
<li><a href="index-all.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="./allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

65
Lfraction/index.html Normal file
View File

@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Generated Documentation (Untitled)</title>
<script type="text/javascript">
targetPage = "" + window.location.search;
if (targetPage != "" && targetPage != "undefined")
targetPage = targetPage.substring(1);
if (targetPage.indexOf(":") != -1 || (targetPage != "" && !validURL(targetPage)))
targetPage = "undefined";
function validURL(url) {
var pos = url.indexOf(".html");
if (pos == -1 || pos != url.length - 5)
return false;
var allowNumber = false;
var allowSep = false;
var seenDot = false;
for (var i = 0; i < url.length - 5; i++) {
var ch = url.charAt(i);
if ('a' <= ch && ch <= 'z' ||
'A' <= ch && ch <= 'Z' ||
ch == '$' ||
ch == '_') {
allowNumber = true;
allowSep = true;
} else if ('0' <= ch && ch <= '9'
|| ch == '-') {
if (!allowNumber)
return false;
} else if (ch == '/' || ch == '.') {
if (!allowSep)
return false;
allowNumber = false;
allowSep = false;
if (ch == '.')
seenDot = true;
if (ch == '/' && seenDot)
return false;
} else {
return false;
}
}
return true;
}
function loadFrames() {
if (targetPage != "" && targetPage != "undefined")
top.classFrame.location = top.targetPage;
}
</script>
</head>
<frameset cols="20%,80%" title="Documentation frame" onload="top.loadFrames()">
<frame src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
<frame src="Lfraction.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
<noframes>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<h2>Frame Alert</h2>
<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="Lfraction.html">Non-frame version</a>.</p>
</noframes>
</frameset>
</html>

View File

@ -0,0 +1,121 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>Class Hierarchy</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Class Hierarchy";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?overview-tree.html" target="_top">Frames</a></li>
<li><a href="overview-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">Hierarchy For All Packages</h1>
</div>
<div class="contentContainer">
<h2 title="Class Hierarchy">Class Hierarchy</h2>
<ul>
<li type="circle">java.lang.Object
<ul>
<li type="circle"><a href="Lfraction.html" title="class in &lt;Unnamed&gt;"><span class="strong">Lfraction</span></a> (implements java.lang.Comparable&lt;T&gt;)</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?overview-tree.html" target="_top">Frames</a></li>
<li><a href="overview-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title>&amp;lt;Unnamed&amp;gt;</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<h1 class="bar"><a href="package-summary.html" target="classFrame">&lt;Unnamed&gt;</a></h1>
<div class="indexContainer">
<h2 title="Classes">Classes</h2>
<ul title="Classes">
<li><a href="Lfraction.html" title="class in &lt;Unnamed&gt;" target="classFrame">Lfraction</a></li>
</ul>
</div>
</body>
</html>

1
Lfraction/package-list Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,126 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li>Next Package</li>
</ul>
<ul class="navList">
<li><a href="index.html?package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package&nbsp;&lt;Unnamed&gt;</h1>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="Lfraction.html" title="class in &lt;Unnamed&gt;">Lfraction</a></td>
<td class="colLast">
<div class="block">This class presents fractions of form n/d where n and d are long integer
numbers.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li>Next Package</li>
</ul>
<ul class="navList">
<li><a href="index.html?package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

121
Lfraction/package-tree.html Normal file
View File

@ -0,0 +1,121 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_25) on Fri Sep 20 13:54:02 EEST 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<title> Class Hierarchy</title>
<meta name="date" content="2013-09-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title=" Class Hierarchy";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">Hierarchy For Package &lt;Unnamed&gt;</h1>
</div>
<div class="contentContainer">
<h2 title="Class Hierarchy">Class Hierarchy</h2>
<ul>
<li type="circle">java.lang.Object
<ul>
<li type="circle"><a href="Lfraction.html" title="class in &lt;Unnamed&gt;"><span class="strong">Lfraction</span></a> (implements java.lang.Comparable&lt;T&gt;)</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-all.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
Lfraction/resources/tab.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

474
Lfraction/stylesheet.css Normal file
View File

@ -0,0 +1,474 @@
/* Javadoc style sheet */
/*
Overall document style
*/
body {
background-color:#ffffff;
color:#353833;
font-family:Arial, Helvetica, sans-serif;
font-size:76%;
margin:0;
}
a:link, a:visited {
text-decoration:none;
color:#4c6b87;
}
a:hover, a:focus {
text-decoration:none;
color:#bb7a2a;
}
a:active {
text-decoration:none;
color:#4c6b87;
}
a[name] {
color:#353833;
}
a[name]:hover {
text-decoration:none;
color:#353833;
}
pre {
font-size:1.3em;
}
h1 {
font-size:1.8em;
}
h2 {
font-size:1.5em;
}
h3 {
font-size:1.4em;
}
h4 {
font-size:1.3em;
}
h5 {
font-size:1.2em;
}
h6 {
font-size:1.1em;
}
ul {
list-style-type:disc;
}
code, tt {
font-size:1.2em;
}
dt code {
font-size:1.2em;
}
table tr td dt code {
font-size:1.2em;
vertical-align:top;
}
sup {
font-size:.6em;
}
/*
Document title and Copyright styles
*/
.clear {
clear:both;
height:0px;
overflow:hidden;
}
.aboutLanguage {
float:right;
padding:0px 21px;
font-size:.8em;
z-index:200;
margin-top:-7px;
}
.legalCopy {
margin-left:.5em;
}
.bar a, .bar a:link, .bar a:visited, .bar a:active {
color:#FFFFFF;
text-decoration:none;
}
.bar a:hover, .bar a:focus {
color:#bb7a2a;
}
.tab {
background-color:#0066FF;
background-image:url(resources/titlebar.gif);
background-position:left top;
background-repeat:no-repeat;
color:#ffffff;
padding:8px;
width:5em;
font-weight:bold;
}
/*
Navigation bar styles
*/
.bar {
background-image:url(resources/background.gif);
background-repeat:repeat-x;
color:#FFFFFF;
padding:.8em .5em .4em .8em;
height:auto;/*height:1.8em;*/
font-size:1em;
margin:0;
}
.topNav {
background-image:url(resources/background.gif);
background-repeat:repeat-x;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
}
.bottomNav {
margin-top:10px;
background-image:url(resources/background.gif);
background-repeat:repeat-x;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
}
.subNav {
background-color:#dee3e9;
border-bottom:1px solid #9eadc0;
float:left;
width:100%;
overflow:hidden;
}
.subNav div {
clear:left;
float:left;
padding:0 0 5px 6px;
}
ul.navList, ul.subNavList {
float:left;
margin:0 25px 0 0;
padding:0;
}
ul.navList li{
list-style:none;
float:left;
padding:3px 6px;
}
ul.subNavList li{
list-style:none;
float:left;
font-size:90%;
}
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
color:#FFFFFF;
text-decoration:none;
}
.topNav a:hover, .bottomNav a:hover {
text-decoration:none;
color:#bb7a2a;
}
.navBarCell1Rev {
background-image:url(resources/tab.gif);
background-color:#a88834;
color:#FFFFFF;
margin: auto 5px;
border:1px solid #c9aa44;
}
/*
Page header and footer styles
*/
.header, .footer {
clear:both;
margin:0 20px;
padding:5px 0 0 0;
}
.indexHeader {
margin:10px;
position:relative;
}
.indexHeader h1 {
font-size:1.3em;
}
.title {
color:#2c4557;
margin:10px 0;
}
.subTitle {
margin:5px 0 0 0;
}
.header ul {
margin:0 0 25px 0;
padding:0;
}
.footer ul {
margin:20px 0 5px 0;
}
.header ul li, .footer ul li {
list-style:none;
font-size:1.2em;
}
/*
Heading styles
*/
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
background-color:#dee3e9;
border-top:1px solid #9eadc0;
border-bottom:1px solid #9eadc0;
margin:0 0 6px -8px;
padding:2px 5px;
}
ul.blockList ul.blockList ul.blockList li.blockList h3 {
background-color:#dee3e9;
border-top:1px solid #9eadc0;
border-bottom:1px solid #9eadc0;
margin:0 0 6px -8px;
padding:2px 5px;
}
ul.blockList ul.blockList li.blockList h3 {
padding:0;
margin:15px 0;
}
ul.blockList li.blockList h2 {
padding:0px 0 20px 0;
}
/*
Page layout container styles
*/
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
clear:both;
padding:10px 20px;
position:relative;
}
.indexContainer {
margin:10px;
position:relative;
font-size:1.0em;
}
.indexContainer h2 {
font-size:1.1em;
padding:0 0 3px 0;
}
.indexContainer ul {
margin:0;
padding:0;
}
.indexContainer ul li {
list-style:none;
}
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
font-size:1.1em;
font-weight:bold;
margin:10px 0 0 0;
color:#4E4E4E;
}
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
margin:10px 0 10px 20px;
}
.serializedFormContainer dl.nameValue dt {
margin-left:1px;
font-size:1.1em;
display:inline;
font-weight:bold;
}
.serializedFormContainer dl.nameValue dd {
margin:0 0 0 1px;
font-size:1.1em;
display:inline;
}
/*
List styles
*/
ul.horizontal li {
display:inline;
font-size:0.9em;
}
ul.inheritance {
margin:0;
padding:0;
}
ul.inheritance li {
display:inline;
list-style:none;
}
ul.inheritance li ul.inheritance {
margin-left:15px;
padding-left:15px;
padding-top:1px;
}
ul.blockList, ul.blockListLast {
margin:10px 0 10px 0;
padding:0;
}
ul.blockList li.blockList, ul.blockListLast li.blockList {
list-style:none;
margin-bottom:25px;
}
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
padding:0px 20px 5px 10px;
border:1px solid #9eadc0;
background-color:#f9f9f9;
}
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
padding:0 0 5px 8px;
background-color:#ffffff;
border:1px solid #9eadc0;
border-top:none;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
margin-left:0;
padding-left:0;
padding-bottom:15px;
border:none;
border-bottom:1px solid #9eadc0;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
list-style:none;
border-bottom:none;
padding-bottom:0;
}
table tr td dl, table tr td dl dt, table tr td dl dd {
margin-top:0;
margin-bottom:1px;
}
/*
Table styles
*/
.contentContainer table, .classUseContainer table, .constantValuesContainer table {
border-bottom:1px solid #9eadc0;
width:100%;
}
.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
width:100%;
}
.contentContainer .description table, .contentContainer .details table {
border-bottom:none;
}
.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{
vertical-align:top;
padding-right:20px;
}
.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast,
.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast,
.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne,
.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne {
padding-right:3px;
}
.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
position:relative;
text-align:left;
background-repeat:no-repeat;
color:#FFFFFF;
font-weight:bold;
clear:none;
overflow:hidden;
padding:0px;
margin:0px;
}
caption a:link, caption a:hover, caption a:active, caption a:visited {
color:#FFFFFF;
}
.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
white-space:nowrap;
padding-top:8px;
padding-left:8px;
display:block;
float:left;
background-image:url(resources/titlebar.gif);
height:18px;
}
.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
width:10px;
background-image:url(resources/titlebar_end.gif);
background-repeat:no-repeat;
background-position:top right;
position:relative;
float:left;
}
ul.blockList ul.blockList li.blockList table {
margin:0 0 12px 0px;
width:100%;
}
.tableSubHeadingColor {
background-color: #EEEEFF;
}
.altColor {
background-color:#eeeeef;
}
.rowColor {
background-color:#ffffff;
}
.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
text-align:left;
padding:3px 3px 3px 7px;
}
th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
background:#dee3e9;
border-top:1px solid #9eadc0;
border-bottom:1px solid #9eadc0;
text-align:left;
padding:3px 3px 3px 7px;
}
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
font-weight:bold;
}
td.colFirst, th.colFirst {
border-left:1px solid #9eadc0;
white-space:nowrap;
}
td.colLast, th.colLast {
border-right:1px solid #9eadc0;
}
td.colOne, th.colOne {
border-right:1px solid #9eadc0;
border-left:1px solid #9eadc0;
}
table.overviewSummary {
padding:0px;
margin-left:0px;
}
table.overviewSummary td.colFirst, table.overviewSummary th.colFirst,
table.overviewSummary td.colOne, table.overviewSummary th.colOne {
width:25%;
vertical-align:middle;
}
table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
width:25%;
vertical-align:middle;
}
/*
Content styles
*/
.description pre {
margin-top:0;
}
.deprecatedContent {
margin:0;
padding:10px 0;
}
.docSummary {
padding:0;
}
/*
Formatting effect styles
*/
.sourceLineNo {
color:green;
padding:0 30px 0 0;
}
h1.hidden {
visibility:hidden;
overflow:hidden;
font-size:.9em;
}
.block {
display:block;
margin:3px 0 0 0;
}
.strong {
font-weight:bold;
}

57
README.md Normal file
View File

@ -0,0 +1,57 @@
# README #
See on neljanda kodutöö failide hoidla, mida saab kasutada ainult algseks lugemiseks.
Töötamiseks looge endale isiklik repositoorium, näiteks privaatne 'fork' bitbucket serverisse, millest saate luua klooni oma arvutisse.
## Näidete kasutamine käsurealt ##
#### Kompileerimine: ####
```
#!bash
javac -cp src src/Lfraction.java
```
#### Käivitamine: ####
```
#!bash
java -cp src Lfraction
```
### Testide kasutamine ###
#### Testi kompileerimine: ####
```
#!bash
javac -encoding utf8 -cp 'src:test:test/junit-4.12.jar:test/hamcrest-core-1.3.jar' test/LfractionTest.java
```
Sama Windows aknas (koolonite asemel peavad olema semikoolonid):
```
#!bash
javac -encoding utf8 -cp 'src;test;test/junit-4.12.jar;test/hamcrest-core-1.3.jar' test/LfractionTest.java
```
#### Testi käivitamine: ####
```
#!bash
java -cp 'src:test:test/junit-4.12.jar:test/hamcrest-core-1.3.jar' org.junit.runner.JUnitCore LfractionTest
```
Sama Windows aknas (koolonite asemel semikoolonid):
```
#!bash
java -cp 'src;test;test/junit-4.12.jar;test/hamcrest-core-1.3.jar' org.junit.runner.JUnitCore LfractionTest
```

69
description.html Normal file
View File

@ -0,0 +1,69 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>i231.fraction.v2</title>
</head>
<body>
Write an implementation (class <code>Lfraction</code>) for an abstract data
type "Fraction", where the fraction consists of two long integers:
numerator and denominator. Always convert
fractions to a form, where denominator is strictly positive and
the fraction is reduced. By default all operations (described on webpage
http://www.itcollege.ee/~jpoial/algoritmid/Lfraction/index.html ) must be exact
and use integer arithmetics only (e.g. do not use floating point arithmetics
to compare two fractions).
<br><br>
Remark 1. In addition to public methods listed you may need
a method to find the greatest common divisor of two integers to reduce
the fractions.
<br>
Remark 2. Operations must not modify operands, a new fraction must be
created for the result.
<br>
Remark 3. Methods <code>toString</code> and <code>valueOf</code> must
be dual: method <code>valueOf</code> must be able to interpret all
strings generated by the method <code>toString</code> .
<br>
Remark 4. If an error occurs (division by zero, illegal string, etc.)
the program must throw an exception of class <code>RuntimeException</code>
(or any appropriate subclass of <code>RuntimeException</code>).
<br>
Remark 5. Sign of a fraction is in numerator and integer numbers
expressed as fractions must have denominator 1, e.g.
3 is 3/1 , -5 is (-5)/1 and 0 is 0/1 .
<br><br>
Realiseerida abstraktne andmetüüp "murd pikkade täisarvude paarina".
<br>
Murdu esindab objekt klassist <code>Lfraction</code>, mis sisaldab murru
lugejat (ingl.k. numerator) ja murru nimetajat (ingl.k. denominator)
pikkade täisarvudena (teha nii, et nimetaja oleks alati rangelt positiivne
ning murd taandatud).
<br>
Realiseerida kõik operatsioonid, mis on kirjeldatud programmitoorikus (ja
veebilehel http://www.itcollege.ee/~jpoial/algoritmid/Lfraction/index.html ).
Murdude võrdlus peab olema täpne, s.t. toetuma arvutustele täisarvudega,
mitte reaalarvuliste lähiväärtustega.
<br><br>
Märkus 1. Lisaks loetletud avalikele meetoditele on teil tõenäoliselt
tarvis murru taandamise meetodit ja võib-olla ka kahe täisarvu
suurima ühisteguri leidmise meetodit.
<br>
Märkus 2. Reeglina ei tohi meetodid muuta objekti, millele neid rakendatakse
(näit. liitmisel ei tohi muuta liidetavaid, tuleb summa jaoks luua uus murd).
<br>
Märkus 3. Sõne teisendamisel murruks peab <code>valueOf</code>-meetod
olema kooskõlas <code>toString</code>-meetodiga (peab oskama tõlgendada
niisugust sõnet, mida <code>toString</code> tagastab).
<br>
Märkus 4. Veasituatsioonid (sõne, mida ei saa teisendada; nulliga jagamine
jt.) peavad tekitama erindi klassist <code>RuntimeException</code> või mõnest
selle klassi sobivast alamklassist.
<br>
Märkus 5. Murru märk käib lugeja juurde ning täisarvude nimetaja on 1 (ka
arvu 0 puhul).
<br><br>
</body>
</html>

164
src/Lfraction.java Normal file
View File

@ -0,0 +1,164 @@
import java.util.*;
/** This class presents fractions of form n/d where n and d are long integer
* numbers. Basic operations and arithmetics for fractions are provided.
*/
public class Lfraction implements Comparable<Lfraction> {
/** Main method. Different tests. */
public static void main (String[] param) {
// TODO!!! Your debugging tests here
}
// TODO!!! instance variables here
/** Constructor.
* @param a numerator
* @param b denominator > 0
*/
public Lfraction (long a, long b) {
// TODO!!!
}
/** Public method to access the numerator field.
* @return numerator
*/
public long getNumerator() {
return 0L; // TODO!!!
}
/** Public method to access the denominator field.
* @return denominator
*/
public long getDenominator() {
return 1L; // TODO!!!
}
/** Conversion to string.
* @return string representation of the fraction
*/
@Override
public String toString() {
return ""; // TODO!!!
}
/** Equality test.
* @param m second fraction
* @return true if fractions this and m are equal
*/
@Override
public boolean equals (Object m) {
return false; // TODO!!!
}
/** Hashcode has to be equal for equal fractions.
* @return hashcode
*/
@Override
public int hashCode() {
return 0; // TODO!!!
}
/** Sum of fractions.
* @param m second addend
* @return this+m
*/
public Lfraction plus (Lfraction m) {
return null; // TODO!!!
}
/** Multiplication of fractions.
* @param m second factor
* @return this*m
*/
public Lfraction times (Lfraction m) {
return null; // TODO!!!
}
/** Inverse of the fraction. n/d becomes d/n.
* @return inverse of this fraction: 1/this
*/
public Lfraction inverse() {
return null; // TODO!!!
}
/** Opposite of the fraction. n/d becomes -n/d.
* @return opposite of this fraction: -this
*/
public Lfraction opposite() {
return null; // TODO!!!
}
/** Difference of fractions.
* @param m subtrahend
* @return this-m
*/
public Lfraction minus (Lfraction m) {
return null; // TODO!!!
}
/** Quotient of fractions.
* @param m divisor
* @return this/m
*/
public Lfraction divideBy (Lfraction m) {
return null; // TODO!!!
}
/** Comparision of fractions.
* @param m second fraction
* @return -1 if this < m; 0 if this==m; 1 if this > m
*/
public int compareTo (Lfraction m) {
return 0; // TODO!!!
}
/** Clone of the fraction.
* @return new fraction equal to this
*/
@Override
public Object clone() throws CloneNotSupportedException {
return null; // TODO!!!
}
/** Integer part of the (improper) fraction.
* @return integer part of this fraction
*/
public long integerPart() {
return 0L; // TODO!!!
}
/** Extract fraction part of the (improper) fraction
* (a proper fraction without the integer part).
* @return fraction part of this fraction
*/
public Lfraction fractionPart() {
return null; // TODO!!!
}
/** Approximate value of the fraction.
* @return numeric value of this fraction
*/
public double toDouble() {
return 0.; // TODO!!!
}
/** Double value f presented as a fraction with denominator d > 0.
* @param f real number
* @param d positive denominator for the result
* @return f as an approximate fraction of form n/d
*/
public static Lfraction toLfraction (double f, long d) {
return null; // TODO!!!
}
/** Conversion from string to the fraction. Accepts strings of form
* that is defined by the toString method.
* @param s string form (as produced by toString) of the fraction
* @return fraction represented by s
*/
public static Lfraction valueOf (String s) {
return null; // TODO!!!
}
}

552
src/TextIO.java Normal file
View File

@ -0,0 +1,552 @@
/*
The file defines a class TextIO, which provides a simple interface
to Java's standard console input and output. This class defines
several static methods for reading and writing
values of various type.
This class will only work with standard, interactive applications.
When it is used in such an application, System.out and System.in
should not be used directly, since the TextIO class thinks it has
exclusive control of System.out and System.in. (Actually, using
System.out will probably not cause any problems, but don't use
System.in.)
To use this class in your program, simply include the compiled class
file TextIO.class in the same directory with the class file for your
main program. (If you are using a development environment such as
CodeWarrior or Visual J++, you can include the source file,
TextIO.java in your project.) You can then use all the public static methods
from the TextIO class in your program. (In your programs, the names
of the methods must be prefaced with "TextIO." For example, you should
use the name TextIO.getln() rather than simply getln().)
(This class is for use with my on-line introductory java textbook,
which is available at http://math.hws.edu/eck/cs124/notes/index.html.)
Written by: David Eck
Department of Mathematics and Computer Science
Hobart and William Smith Colleges
Geneva, NY 14456
Email: eck@hws.edu
WWW: http://math.hws.edu/eck/
July 16, 1998
Modified February, 2000; getChar() now skips blanks and CR's, and getAnyChar()
can be used to read the next char even if it's a blank or CR.
*/
import java.io.*;
public class TextIO {
// *************************** I/O Methods *********************************
// Methods for writing the primitive types, plus type String,
// to the console, with no extra spaces.
//
// Note that the real-number data types, float
// and double, a rounded version is output that will
// use at most 10 or 11 characters. If you want to
// output a real number with full accuracy, use
// "TextIO.put(String.valueOf(x))", for example.
public static void put(int x) { put(x,0); } // Note: also handles byte and short!
public static void put(long x) { put(x,0); }
public static void put(double x) { put(x,0); } // Also handles float.
public static void put(char x) { put(x,0); }
public static void put(boolean x) { put(x,0); }
public static void put(String x) { put(x,0); }
// Methods for writing the primitive types, plus type String,
// to the console,followed by a carriage return, with
// no extra spaces.
public static void putln(int x) { put(x,0); newLine(); } // Note: also handles byte and short!
public static void putln(long x) { put(x,0); newLine(); }
public static void putln(double x) { put(x,0); newLine(); } // Also handles float.
public static void putln(char x) { put(x,0); newLine(); }
public static void putln(boolean x) { put(x,0); newLine(); }
public static void putln(String x) { put(x,0); newLine(); }
// Methods for writing the primitive types, plus type String,
// to the console, with a minimum field width of w,
// and followed by a carriage return.
// If output value is less than w characters, it is padded
// with extra spaces in front of the value.
public static void putln(int x, int w) { put(x,w); newLine(); } // Note: also handles byte and short!
public static void putln(long x, int w) { put(x,w); newLine(); }
public static void putln(double x, int w) { put(x,w); newLine(); } // Also handles float.
public static void putln(char x, int w) { put(x,w); newLine(); }
public static void putln(boolean x, int w) { put(x,w); newLine(); }
public static void putln(String x, int w) { put(x,w); newLine(); }
// Method for outputting a carriage return
public static void putln() { newLine(); }
// Methods for writing the primitive types, plus type String,
// to the console, with minimum field width w.
public static void put(int x, int w) { dumpString(String.valueOf(x), w); } // Note: also handles byte and short!
public static void put(long x, int w) { dumpString(String.valueOf(x), w); }
public static void put(double x, int w) { dumpString(realToString(x), w); } // Also handles float.
public static void put(char x, int w) { dumpString(String.valueOf(x), w); }
public static void put(boolean x, int w) { dumpString(String.valueOf(x), w); }
public static void put(String x, int w) { dumpString(x, w); }
// Methods for reading in the primitive types, plus "words" and "lines".
// The "getln..." methods discard any extra input, up to and including
// the next carriage return.
// A "word" read by getlnWord() is any sequence of non-blank characters.
// A "line" read by getlnString() or getln() is everything up to next CR;
// the carriage return is not part of the returned value, but it is
// read and discarded.
// Note that all input methods except getAnyChar(), peek(), the ones for lines
// skip past any blanks and carriage returns to find a non-blank value.
// getln() can return an empty string; getChar() and getlnChar() can
// return a space or a linefeed ('\n') character.
// peek() allows you to look at the next character in input, without
// removing it from the input stream. (Note that using this
// routine might force the user to enter a line, in order to
// check what the next character is.)
// Acceptable boolean values are the "words": true, false, t, f, yes,
// no, y, n, 0, or 1; uppercase letters are OK.
// None of these can produce an error; if an error is found in input,
// the user is forced to re-enter.
// Available input routines are:
//
// getByte() getlnByte() getShort() getlnShort()
// getInt() getlnInt() getLong() getlnLong()
// getFloat() getlnFloat() getDouble() getlnDouble()
// getChar() getlnChar() peek() getAnyChar()
// getWord() getlnWord() getln() getString() getlnString()
//
// (getlnString is the same as getln and is only provided for consistency.)
public static byte getlnByte() { byte x=getByte(); emptyBuffer(); return x; }
public static short getlnShort() { short x=getShort(); emptyBuffer(); return x; }
public static int getlnInt() { int x=getInt(); emptyBuffer(); return x; }
public static long getlnLong() { long x=getLong(); emptyBuffer(); return x; }
public static float getlnFloat() { float x=getFloat(); emptyBuffer(); return x; }
public static double getlnDouble() { double x=getDouble(); emptyBuffer(); return x; }
public static char getlnChar() { char x=getChar(); emptyBuffer(); return x; }
public static boolean getlnBoolean() { boolean x=getBoolean(); emptyBuffer(); return x; }
public static String getlnWord() { String x=getWord(); emptyBuffer(); return x; }
public static String getlnString() { return getln(); } // same as getln()
public static String getln() {
StringBuffer s = new StringBuffer(100);
char ch = readChar();
while (ch != '\n') {
s.append(ch);
ch = readChar();
}
return s.toString();
}
public static byte getByte() { return (byte)readInteger(-128L,127L); }
public static short getShort() { return (short)readInteger(-32768L,32767L); }
public static int getInt() { return (int)readInteger((long)Integer.MIN_VALUE, (long)Integer.MAX_VALUE); }
public static long getLong() { return readInteger(Long.MIN_VALUE, Long.MAX_VALUE); }
public static char getAnyChar(){ return readChar(); }
public static char peek() { return lookChar(); }
public static char getChar() { // skip spaces & cr's, then return next char
char ch = lookChar();
while (ch == ' ' || ch == '\n') {
readChar();
if (ch == '\n')
dumpString("? ",0);
ch = lookChar();
}
return readChar();
}
public static float getFloat() {
float x = 0.0F;
while (true) {
String str = readRealString();
if (str.equals("")) {
errorMessage("Illegal floating point input.",
"Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE);
}
else {
Float f = null;
try { f = Float.valueOf(str); }
catch (NumberFormatException e) {
errorMessage("Illegal floating point input.",
"Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE);
continue;
}
if (f.isInfinite()) {
errorMessage("Floating point input outside of legal range.",
"Real number in the range " + Float.MIN_VALUE + " to " + Float.MAX_VALUE);
continue;
}
x = f.floatValue();
break;
}
}
return x;
}
public static double getDouble() {
double x = 0.0;
while (true) {
String str = readRealString();
if (str.equals("")) {
errorMessage("Illegal floating point input",
"Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE);
}
else {
Double f = null;
try { f = Double.valueOf(str); }
catch (NumberFormatException e) {
errorMessage("Illegal floating point input",
"Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE);
continue;
}
if (f.isInfinite()) {
errorMessage("Floating point input outside of legal range.",
"Real number in the range " + Double.MIN_VALUE + " to " + Double.MAX_VALUE);
continue;
}
x = f.doubleValue();
break;
}
}
return x;
}
public static String getWord() {
char ch = lookChar();
while (ch == ' ' || ch == '\n') {
readChar();
if (ch == '\n')
dumpString("? ",0);
ch = lookChar();
}
StringBuffer str = new StringBuffer(50);
while (ch != ' ' && ch != '\n') {
str.append(readChar());
ch = lookChar();
}
return str.toString();
}
public static boolean getBoolean() {
boolean ans = false;
while (true) {
String s = getWord();
if ( s.equalsIgnoreCase("true") || s.equalsIgnoreCase("t") ||
s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("y") ||
s.equals("1") ) {
ans = true;
break;
}
else if ( s.equalsIgnoreCase("false") || s.equalsIgnoreCase("f") ||
s.equalsIgnoreCase("no") || s.equalsIgnoreCase("n") ||
s.equals("0") ) {
ans = false;
break;
}
else
errorMessage("Illegal boolean input value.",
"one of: true, false, t, f, yes, no, y, n, 0, or 1");
}
return ans;
}
// ***************** Everything beyond this point is private *******************
// ********************** Utility routines for input/output ********************
private static InputStream in = System.in; // rename standard input stream
private static PrintStream out = System.out; // rename standard output stream
private static String buffer = null; // one line read from input
private static int pos = 0; // position of next char in input line that has
// not yet been processed
private static String readRealString() { // read chars from input following syntax of real numbers
StringBuffer s=new StringBuffer(50);
char ch=lookChar();
while (ch == ' ' || ch == '\n') {
readChar();
if (ch == '\n')
dumpString("? ",0);
ch = lookChar();
}
if (ch == '-' || ch == '+') {
s.append(readChar());
ch = lookChar();
while (ch == ' ') {
readChar();
ch = lookChar();
}
}
while (ch >= '0' && ch <= '9') {
s.append(readChar());
ch = lookChar();
}
if (ch == '.') {
s.append(readChar());
ch = lookChar();
while (ch >= '0' && ch <= '9') {
s.append(readChar());
ch = lookChar();
}
}
if (ch == 'E' || ch == 'e') {
s.append(readChar());
ch = lookChar();
if (ch == '-' || ch == '+') {
s.append(readChar());
ch = lookChar();
}
while (ch >= '0' && ch <= '9') {
s.append(readChar());
ch = lookChar();
}
}
return s.toString();
}
private static long readInteger(long min, long max) { // read long integer, limited to specified range
long x=0;
while (true) {
StringBuffer s=new StringBuffer(34);
char ch=lookChar();
while (ch == ' ' || ch == '\n') {
readChar();
if (ch == '\n')
dumpString("? ",0);
ch = lookChar();
}
if (ch == '-' || ch == '+') {
s.append(readChar());
ch = lookChar();
while (ch == ' ') {
readChar();
ch = lookChar();
}
}
while (ch >= '0' && ch <= '9') {
s.append(readChar());
ch = lookChar();
}
if (s.equals("")){
errorMessage("Illegal integer input.",
"Integer in the range " + min + " to " + max);
}
else {
String str = s.toString();
try {
x = Long.parseLong(str);
}
catch (NumberFormatException e) {
errorMessage("Illegal integer input.",
"Integer in the range " + min + " to " + max);
continue;
}
if (x < min || x > max) {
errorMessage("Integer input outside of legal range.",
"Integer in the range " + min + " to " + max);
continue;
}
break;
}
}
return x;
}
private static String realToString(double x) {
// Goal is to get a reasonable representation of x in at most
// 10 characters, or 11 characters if x is negative.
if (Double.isNaN(x))
return "undefined";
if (Double.isInfinite(x))
if (x < 0)
return "-INF";
else
return "INF";
if (Math.abs(x) <= 5000000000.0 && Math.rint(x) == x)
return String.valueOf( (long)x );
String s = String.valueOf(x);
if (s.length() <= 10)
return s;
boolean neg = false;
if (x < 0) {
neg = true;
x = -x;
s = String.valueOf(x);
}
if (x >= 0.00005 && x <= 50000000 && (s.indexOf('E') == -1 && s.indexOf('e') == -1)) { // trim x to 10 chars max
s = round(s,10);
s = trimZeros(s);
}
else if (x > 1) { // construct exponential form with positive exponent
long power = (long)Math.floor(Math.log(x)/Math.log(10));
String exp = "E" + power;
int numlength = 10 - exp.length();
x = x / Math.pow(10,power);
s = String.valueOf(x);
s = round(s,numlength);
s = trimZeros(s);
s += exp;
}
else { // constuct exponential form
long power = (long)Math.ceil(-Math.log(x)/Math.log(10));
String exp = "E-" + power;
int numlength = 10 - exp.length();
x = x * Math.pow(10,power);
s = String.valueOf(x);
s = round(s,numlength);
s = trimZeros(s);
s += exp;
}
if (neg)
return "-" + s;
else
return s;
}
private static String trimZeros(String num) { // used by realToString
if (num.indexOf('.') >= 0 && num.charAt(num.length() - 1) == '0') {
int i = num.length() - 1;
while (num.charAt(i) == '0')
i--;
if (num.charAt(i) == '.')
num = num.substring(0,i);
else
num = num.substring(0,i+1);
}
return num;
}
private static String round(String num, int length) { // used by realToString
if (num.indexOf('.') < 0)
return num;
if (num.length() <= length)
return num;
if (num.charAt(length) >= '5' && num.charAt(length) != '.') {
char[] temp = new char[length+1];
int ct = length;
boolean rounding = true;
for (int i = length-1; i >= 0; i--) {
temp[ct] = num.charAt(i);
if (rounding && temp[ct] != '.') {
if (temp[ct] < '9') {
temp[ct]++;
rounding = false;
}
else
temp[ct] = '0';
}
ct--;
}
if (rounding) {
temp[ct] = '1';
ct--;
}
// ct is -1 or 0
return new String(temp,ct+1,length-ct);
}
else
return num.substring(0,length);
}
private static void dumpString(String str, int w) { // output string to console
for (int i=str.length(); i<w; i++)
out.print(' ');
for (int i=0; i<str.length(); i++)
if ((int)str.charAt(i) >= 0x20 && (int)str.charAt(i) != 0x7F) // no control chars or delete
out.print(str.charAt(i));
else if (str.charAt(i) == '\n' || str.charAt(i) == '\r')
newLine();
}
private static void errorMessage(String message, String expecting) {
// inform user of error and force user to re-enter.
newLine();
dumpString(" *** Error in input: " + message + "\n", 0);
dumpString(" *** Expecting: " + expecting + "\n", 0);
dumpString(" *** Discarding Input: ", 0);
if (lookChar() == '\n')
dumpString("(end-of-line)\n\n",0);
else {
while (lookChar() != '\n')
out.print(readChar());
dumpString("\n\n",0);
}
dumpString("Please re-enter: ", 0);
readChar(); // discard the end-of-line character
}
private static char lookChar() { // return next character from input
if (buffer == null || pos > buffer.length())
fillBuffer();
if (pos == buffer.length())
return '\n';
return buffer.charAt(pos);
}
private static char readChar() { // return and discard next character from input
char ch = lookChar();
pos++;
return ch;
}
private static void newLine() { // output a CR to console
out.println();
out.flush();
}
private static boolean possibleLinefeedPending = false;
private static void fillBuffer() { // Wait for user to type a line and press return,
// and put the typed line into the buffer.
StringBuffer b = new StringBuffer();
out.flush();
try {
int ch = in.read();
if (ch == '\n' && possibleLinefeedPending)
ch = in.read();
possibleLinefeedPending = false;
while (ch != -1 && ch != '\n' && ch != '\r') {
b.append((char)ch);
ch = in.read();
}
possibleLinefeedPending = (ch == '\r');
if (ch == -1) {
System.out.println("\n*** Found an end-of-file while trying to read from standard input!");
System.out.println("*** Maybe your Java system doesn't implement standard input?");
System.out.println("*** Program will be terminated.\n");
throw new RuntimeException("End-of-file on standard input.");
}
}
catch (IOException e) {
System.out.println("Unexpected system error on input.");
System.out.println("Terminating program.");
System.exit(1);
}
buffer = b.toString();
pos = 0;
}
private static void emptyBuffer() { // discard the rest of the current line of input
buffer = null;
}
} // end of class TextIO

261
test/Aout.java Normal file
View File

@ -0,0 +1,261 @@
/** Helper methods.
* Arrays converted to array expressions (toString(...))
* and prettyprinting (toPrettyString(...)).
* @author Jaanus
*/
public class Aout {
/** Just testing. */
public static void main (String[] args) {
System.out.println (toString (new String[]
{null, "", "0", "a\nb", " ", " ", "\t", "möäüÕga", "\"", "\\", "\'"}));
} // main
/** Conversion for int[][] . */
public static String toString (int[][] m) {
if (m == null) return "(int[][])null";
StringBuffer sb = new StringBuffer();
sb.append ("new int[][]{");
for (int i=0; i < m.length; i++) {
if (i > 0) sb.append (", ");
if (m[i] == null)
sb.append ("null");
else {
sb.append ("{");
for (int j=0; j < m[i].length; j++) {
if (j > 0) sb.append (", ");
sb.append (String.valueOf (m[i][j]));
} // for j
sb.append ("}");
}
} // for i
sb.append ("}");
return sb.toString();
} // toString int[][]
/** Conversion for double[][] . */
public static String toString (double[][] m) {
if (m == null) return "(double[][])null";
StringBuffer sb = new StringBuffer();
sb.append ("new double[][]{");
for (int i=0; i < m.length; i++) {
if (i > 0) sb.append (", ");
if (m[i] == null)
sb.append ("null");
else {
sb.append ("{");
for (int j=0; j < m[i].length; j++) {
if (j > 0) sb.append (", ");
sb.append (String.valueOf (m[i][j]));
} // for j
sb.append ("}");
}
} // for i
sb.append ("}");
return sb.toString();
} // toString double[][]
/** Conversion for int[] . */
public static String toString (int[] m) {
if (m == null) return "(int[])null";
StringBuffer sb = new StringBuffer();
sb.append ("new int[]{");
for (int i=0; i < m.length; i++) {
if (i > 0) sb.append (", ");
sb.append (String.valueOf (m[i]));
} // for i
sb.append ("}");
return sb.toString();
} // toString int[]
/** Conversion for double[] . */
public static String toString (double[] m) {
if (m == null) return "(double[])null";
StringBuffer sb = new StringBuffer();
sb.append ("new double[]{");
for (int i=0; i < m.length; i++) {
if (i > 0) sb.append (", ");
sb.append (String.valueOf (m[i]));
} // for i
sb.append ("}");
return sb.toString();
} // toString double[]
/** Conversion for int . */
public static String toString (int n) {
return String.valueOf (n);
} // toString int
/** Conversion for double . */
public static String toString (double d) {
return String.valueOf (d);
} // toString double
/** Conversion for String . */
public static String toString (String s) {
if (s == null)
return "null";
StringBuffer tmp = new StringBuffer();
for (int k=0; k < s.length(); k++) {
char c = s.charAt (k);
switch (c) {
case '\n': { tmp.append ("\\n"); break; }
case '\t': { tmp.append ("\\t"); break; }
case '\b': { tmp.append ("\\b"); break; }
case '\f': { tmp.append ("\\f"); break; }
case '\r': { tmp.append ("\\r"); break; }
case '\\': { tmp.append ("\\\\"); break; }
case '\'': { tmp.append ("\\\'"); break; }
case '\"': { tmp.append ("\\\""); break; }
// TODO!!! add more escapes if needed
default: tmp.append (c);
} // switch
} // for k
return "\"" + tmp.toString() + "\"";
} // toString String
/** Conversion for String[] . */
public static String toString (String[] m) {
if (m == null)
return "(String[])null";
StringBuffer sb = new StringBuffer();
sb.append ("new String[]{");
for (int i=0; i < m.length; i++) {
if (i > 0)
sb.append (", ");
sb.append (toString (m[i]));
} // for i
sb.append ("}");
return sb.toString();
} // toString String[]
/** Double number as string with the given length.
* @param d argument
* @param len length
* @return d as string
*/
public static String fString (double d, int len) {
if (len<1)
return "";
// pad on ruum punkti ja v6imaliku miinusm2rgi jaoks
int pad = 1 + ((d<0)?1:0);
// loga on t2isosa numbrikohtade arv
int loga = (int)Math.max (0., Math.log10 (Math.abs (d))) + 1;
// kk on punkti j2rel olevate kohtade arv
int kk = (int)Math.max (len-pad-loga, 0);
String fs = "%" + String.valueOf (len) + "." +
String.valueOf (kk) + "f";
String res = "";
try {
res = String.format ((java.util.Locale)null, fs, d);
} catch (IllegalArgumentException e) {
res = String.valueOf (d);
} // try
return res;
} // fString
/** Prettyprint for double[][] .
* @param m array to print
* @param fs format string for element
* @return m array as multiline string
*/
public static String toPrettyString (double[][] m, String fs) {
String nl = System.getProperty ("line.separator");
if (m == null)
return "nullpointer instead of this matrix" + nl;
// throw new NullPointerException ("(double[][])null"); // alternative
if (m.length == 0)
return "this matrix is empty" + nl;
StringBuffer sb = new StringBuffer(nl);
for (int i=0; i < m.length; i++) {
if (m[i] == null)
sb.append ("nullpointer instead of this row" + nl);
else {
if (m[i].length == 0)
sb.append ("this row is empty");
else {
for (int j=0; j < m[i].length; j++) {
String elem = "";
if (fs == null || fs.length() < 1) {
// TODO!!! keera siit, kui tahad pilti muuta
elem = fString (m[i][j], 6) + "\t";
} else {
try {
elem = String.format ((java.util.Locale)null,
fs, m[i][j]) + " "; // remove space if needed
} catch (IllegalArgumentException e) {
elem = fString (m[i][j], 6) + "\t";
} // try
}
sb.append (elem);
} // for j
} // nonempty row
sb.append (nl);
} // non-null row
} // for i
return sb.toString();
} // toPrettyString double[][]
/** Version of double[][] prettyprint without format string. */
public static String toPrettyString (double[][] m) {
return toPrettyString (m, null);
} // toPrettyString double[][]
/** Prettyprint for int[][] .
* @param m array to print
* @param fs format string for element
* @return m array as a multiline string
*/
public static String toPrettyString (int[][] m, String fs) {
String nl = System.getProperty ("line.separator");
if (m == null)
return "nullpointer instead of this matrix" + nl;
// throw new NullPointerException ("(double[][])null"); // alternative
if (m.length == 0)
return "this matrix is empty" + nl;
StringBuffer sb = new StringBuffer(nl);
for (int i=0; i < m.length; i++) {
if (m[i] == null)
sb.append ("nullpointer instead of this row" + nl);
else {
if (m[i].length == 0)
sb.append ("this row is empty");
else {
for (int j=0; j < m[i].length; j++) {
String elem = "";
if (fs == null || fs.length() < 1)
fs = "%5d"; // TODO!!! keera siit, kui vaja
try {
elem = String.format ((java.util.Locale)null,
fs, m[i][j]) + " "; // remove space if needed
} catch (IllegalArgumentException e) {
elem = String.valueOf (m[i][j]) + "\t";
} // try
sb.append (elem);
} // for j
} // nonempty row
sb.append (nl);
} // non-null row
} // for i
return sb.toString();
} // toPrettyString int[][]
/** Version of int[][] prettyprint without format string. */
public static String toPrettyString (int[][] m) {
return toPrettyString (m, null);
} // toPrettyString int[][]
/** Prettyprint for String[] . */
public static String toPrettyString (String[] m) {
String nl = System.getProperty ("line.separator");
if (m == null) return "(String[])null";
StringBuffer sb = new StringBuffer();
for (int i=0; i < m.length; i++) {
sb.append (toString (m[i]) + nl);
} // for i
return sb.toString();
} // toPrettyString String[]
} // Aout

335
test/LfractionTest.java Normal file
View File

@ -0,0 +1,335 @@
import static org.junit.Assert.*;
import org.junit.Test;
import java.util.*;
/** Testklass.
* @author Jaanus
*/
public class LfractionTest {
@Test (timeout=1000)
public void testPlus() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = new Lfraction (4, 15);
Lfraction sum = f1.plus(f2);
assertEquals ("Wrong sum: <" + f1 + "> + <" + f2 + ">",
new Lfraction (2, 3), sum);
Lfraction sm2 = sum.plus (sum);
assertEquals ("Wrong sum.plus(sum): <2/3> + <2/3>",
new Lfraction (4, 3), sm2);
assertEquals ("Do not change the arguments of the sum",
new Lfraction (2, 3), sum);
f1 = new Lfraction (-1, 250);
f2 = new Lfraction (-1, 375);
sum = f1.plus(f2);
assertEquals ("Wrong sum: <" + f1 + "> + <" + f2 + ">",
new Lfraction (-1, 150), sum);
f1 = new Lfraction (1, 221);
f2 = new Lfraction (1, 323);
sum = f1.plus (f2);
assertEquals ("Wrong sum: <" + f1 + "> + <" + f2 + ">",
new Lfraction (32, 4199), sum);
f1 = new Lfraction (1, 39203);
f2 = new Lfraction (1, 41989);
sum = f1.plus (f2);
assertEquals ("Wrong sum: <" + f1 + "> + <" + f2 + ">",
new Lfraction (408, 8271833), sum);
f1 = new Lfraction (-2, 5);
f2 = new Lfraction (2, 5);
sum = f1.plus(f2);
assertEquals ("Wrong sum: <" + f1 + "> + <" + f2 + ">",
new Lfraction (0, 1), sum);
}
@Test (timeout=1000)
public void testTimes() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = new Lfraction (4, 15);
Lfraction prd = f1.times (f2);
assertEquals ("Wrong product: <" + f1 + "> * <" + f2 + ">",
new Lfraction (8, 75), prd);
f1 = new Lfraction (-3, 5);
f2 = new Lfraction (-5, 7);
prd = f1.times (f2);
assertEquals ("Wrong product: <" + f1 + "> * <" + f2 + ">",
new Lfraction (3, 7), prd);
Lfraction pr2 = prd.times (prd);
assertEquals ("Wrong prd.times(prd): <3/7> * <3/7>",
new Lfraction (9, 49), pr2);
assertEquals ("Do not change the arguments of the product",
new Lfraction (3, 7), prd);
f1 = new Lfraction (0, 1);
f2 = new Lfraction (2, 3);
prd = f1.times (f2);
assertEquals ("Wrong product: <" + f1 + "> * <" + f2 + ">",
new Lfraction (0, 1), prd);
f1 = new Lfraction (3, 2);
f2 = new Lfraction (2, 3);
prd = f1.times (f2);
assertEquals ("Wrong product: <" + f1 + "> * <" + f2 + ">",
new Lfraction (1, 1), prd);
f1 = new Lfraction (3, 5);
f2 = new Lfraction (5, 7);
prd = f1.times (f2);
assertTrue ("Result must be reduced: 3/5 * 5/7 -> 3/7",
prd.getDenominator()==7);
}
@Test (expected=RuntimeException.class)
public void testCreateZeroDenominator() {
Lfraction f = new Lfraction (1, 0);
}
@Test (expected=RuntimeException.class)
public void testZeroInverse() {
Lfraction f = new Lfraction (0, 1);
f.inverse();
}
@Test (timeout=1000)
public void testClone() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = null;
try {
f2 = (Lfraction)f1.clone();
} catch (CloneNotSupportedException e) {};
assertNotSame ("clone must differ from original", f2, f1);
assertEquals ("clone must be equal to original", f1, f2);
f1 = f2.plus(f1);
assertEquals ("clone must be independent from original",
new Lfraction (2, 5), f2);
}
@Test (timeout=1000)
public void testToString() {
String s = new Lfraction (1, 4).toString();
assertTrue (s + " must represent quarter",
(s.indexOf('1') < s.indexOf('4')) && (s.indexOf('1') >= 0));
s = new Lfraction (-1, 5).toString();
assertTrue (s + " does not contain minus", s.indexOf('-') >= 0);
}
@Test (expected=RuntimeException.class)
public void testDivideByZero() {
Lfraction f1 = new Lfraction (1, 5);
Lfraction f2 = new Lfraction (0, 1);
Lfraction q = f1.divideBy (f2);
}
@Test (timeout=1000)
public void testMinus() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = new Lfraction (4, 15);
Lfraction dif = f1.minus (f2);
assertEquals ("Wrong difference: <" + f1 + "> - <" + f2 + ">",
new Lfraction (2, 15), dif);
Lfraction df2 = dif.minus (dif);
assertEquals ("Wrong difference: <2/15> - <2/15>",
new Lfraction (0, 1), df2);
assertEquals ("Do not change the arguments of the difference",
new Lfraction (2, 15), dif);
f1 = new Lfraction (-2, 5);
f2 = new Lfraction (-4, 15);
dif = f1.minus (f2);
assertEquals ("Wrong difference: <" + f1 + "> - <" + f2 + ">",
new Lfraction (-2, 15), dif);
}
@Test (timeout=1000)
public void testDivideBy() {
Lfraction f1 = new Lfraction (-2, 7);
Lfraction f2 = new Lfraction (-1, 14);
Lfraction f = f1.divideBy (f2);
assertEquals ("Wrong quotient: <" + f1 + "> / <" + f2 + ">",
new Lfraction (4, 1), f);
f = f2.divideBy (f1);
assertEquals ("Wrong quotient: <" + f1 + "> / <" + f2 + ">",
new Lfraction (1, 4), f);
Lfraction f3 = f.divideBy (f);
assertEquals (f.toString() + " divided by itself",
new Lfraction (1, 1), f3);
assertEquals ("Do not change the arguments of the quotient",
new Lfraction (1, 4), f);
}
@Test (timeout=1000)
public void testOpposite() {
Lfraction f1 = new Lfraction (1, 6);
Lfraction f2 = f1.opposite();
assertEquals ("Wrong opposite", new Lfraction (-1, 6), f2);
assertEquals ("Do not change the argument of opposite",
new Lfraction (1, 6), f1);
f1 = new Lfraction (-4, 75);
f2 = f1.opposite();
assertEquals ("Wrong opposite", new Lfraction (4, 75), f2);
f1 = new Lfraction (0, 1);
f2 = f1.opposite();
assertEquals ("zero must be neutral to opposite", f1, f2);
}
@Test (timeout=1000)
public void testInverse() {
Lfraction f1 = new Lfraction (2, 3);
Lfraction f2 = f1.inverse();
assertEquals ("Wrong inverse ", new Lfraction (3, 2), f2);
assertEquals ("Do not change the argument of inverse",
new Lfraction (2, 3), f1);
f1 = new Lfraction (-4, 75);
f2 = f1.inverse();
assertEquals ("Wrong inverse", new Lfraction (-75, 4), f2);
assertTrue ("Denominator must always be positive",
f2.getDenominator() > 0);
f1 = new Lfraction (1, 1);
f2 = f1.inverse();
assertEquals ("1 must be neutral to inverse", f1, f2);
}
@Test (timeout=1000)
public void testGetters() {
Lfraction f1 = new Lfraction (2, 3);
long num = f1.getNumerator();
assertEquals ("wrong numerator ", 2, num);
f1 = new Lfraction (-4, 75);
num = f1.getNumerator();
assertEquals ("Wrong numerator", -4, num);
f1 = new Lfraction (0, 7);
num = f1.getNumerator();
assertEquals ("Wrong numerator", 0, num);
f1 = new Lfraction (2, 3);
long den = f1.getDenominator();
assertEquals ("wrong denominator ", 3, den);
f1 = new Lfraction (-4, 75);
den = f1.getDenominator();
assertEquals ("Wrong denominator", 75, den);
}
@Test (timeout=1000)
public void testIntegerPart() {
Lfraction f1 = new Lfraction (2, 3);
long i = f1.integerPart();
assertEquals ("wrong integer part ", 0, i);
f1 = new Lfraction (3, 2);
i = f1.integerPart();
assertEquals ("wrong integer part ", 1, i);
f1 = new Lfraction (32, 3);
i = f1.integerPart();
assertEquals ("wrong integer part ", 10, i);
f1 = new Lfraction (33, 3);
i = f1.integerPart();
assertEquals ("wrong integer part ", 11, i);
f1 = new Lfraction (-33, 3);
i = f1.integerPart();
assertEquals ("wrong integer part ", -11, i);
}
@Test (timeout=1000)
public void testLfractionPart() {
Lfraction f1 = new Lfraction (2, 3);
Lfraction i = f1.fractionPart();
assertEquals ("wrong fraction part ", new Lfraction (2, 3), i);
f1 = new Lfraction (3, 2);
i = f1.fractionPart();
assertEquals ("wrong fraction part ", new Lfraction (1, 2), i);
f1 = new Lfraction (32, 3);
i = f1.fractionPart();
assertEquals ("wrong fraction part ", new Lfraction (2, 3), i);
f1 = new Lfraction (33, 3);
i = f1.fractionPart();
assertEquals ("wrong fraction part ", new Lfraction (0, 1), i);
f1 = new Lfraction (-33, 3);
i = f1.fractionPart();
assertEquals ("wrong fraction part ", new Lfraction (0, 1), i);
f1 = new Lfraction (-5, 4);
i = f1.fractionPart();
assertTrue ("wrong fraction part " + i.toString()
+ " for " + f1.toString(),
i.equals (new Lfraction (-1, 4)) || i.equals (new Lfraction (3, 4)));
}
@Test (timeout=1000)
public void testEquals() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = new Lfraction (4, 10);
assertTrue ("2/5 must be equal to 4/10", f1.equals (f2));
assertFalse ("2/5 is not 3/5", f1.equals (new Lfraction (3, 5)));
f1 = new Lfraction (12345678901234567L, 1L);
f2 = new Lfraction (12345678901234568L, 1L);
assertFalse ("12345678901234567/1 is not 12345678901234568/1",
f1.equals (f2));
}
@Test (timeout=1000)
public void testCompareTo() {
Lfraction f1 = new Lfraction (2, 5);
Lfraction f2 = new Lfraction (4, 7);
assertTrue ("2/5 must be less than 4/7", f1.compareTo (f2) < 0);
assertTrue ("2/5 must be equal to 4/10",
f1.compareTo (new Lfraction (4, 10)) == 0);
assertTrue ("4/7 must be greater than 2/5", f2.compareTo (f1) > 0);
f1 = new Lfraction (-2, 5);
f2 = new Lfraction (-4, 7);
assertTrue ("-2/5 must be greater than -4/7", f1.compareTo (f2) > 0);
assertTrue ("-2/5 must be equal to -4/10",
f1.compareTo (new Lfraction (-4, 10)) == 0);
assertTrue ("-4/7 must be less than -2/5", f2.compareTo (f1) < 0);
f1 = new Lfraction (12345678901234567L, 1L);
f2 = new Lfraction (12345678901234568L, 1L);
assertFalse ("12345678901234567/1 is not 12345678901234568/1",
f1.compareTo (f2) == 0);
}
@Test (timeout=1000)
public void testToLfraction() {
Lfraction f1 = Lfraction.toLfraction (Math.PI, 7);
Lfraction f2 = new Lfraction (22, 7);
assertTrue ("Math.PI must be nearly 22/7", f1.equals (f2));
f1 = Lfraction.toLfraction (-10., 2);
f2 = new Lfraction (-20, 2);
assertTrue ("-10. must be -20/2", f1.equals (f2));
}
@Test (timeout=1000)
public void testToDouble() {
Lfraction f = new Lfraction (2, 5);
assertEquals ("2/5 must be nearly 0.4", 0.4, f.toDouble(), 0.00001);
f = new Lfraction (-17, 100);
assertEquals ("-17/100 must be nearly -0.17", -0.17,
f.toDouble(), 0.00001);
}
@Test (timeout=1000)
public void testValueOf() {
Lfraction f = new Lfraction (2, 5);
assertEquals ("valueOf must read back what toString outputs. ",
f, Lfraction.valueOf (f.toString()));
f = new Lfraction (-17, 100);
assertEquals ("valueOf must read back what toString outputs. ",
f, Lfraction.valueOf (f.toString()));
}
@Test (timeout=1000)
public void testHashCode() {
Lfraction q1 = new Lfraction (1L, 2L);
int h1 = q1.hashCode();
Lfraction q2 = new Lfraction (1L, 2L);
int h2 = q2.hashCode();
Lfraction q3 = null;
try {
q3 = (Lfraction)q1.clone();
} catch (CloneNotSupportedException e) {};
int h3 = q3.hashCode();
assertTrue ("hashCode has to be same for equal objects", h1 == h2);
assertTrue ("hashCode has to be same for clone objects", h1 == h3);
assertTrue ("hashCode has to be same for the same object",
h1 == q1.hashCode());
q2 = new Lfraction (0L, 2L);
h2 = q2.hashCode();
q3 = new Lfraction (1L, 3L);
h3 = q3.hashCode();
assertFalse ("hashCode does not depend on numerator", h1 == h2);
assertFalse ("hashCode does not depend on denominator", h1 == h3);
}
}

BIN
test/hamcrest-core-1.3.jar Normal file

Binary file not shown.

BIN
test/junit-4.12.jar Normal file

Binary file not shown.