Commit 25abb541 authored by nargessalehi98's avatar nargessalehi98

add final project

parent 67347509
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Main</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="declaration: class: Main">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Model</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="declaration: class: Model">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="script-dir/jquery-ui.js"></script>
</head>
<body class="class-declaration">
<script type="text/javascript">var pathtoroot = "./";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="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-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<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>Method</li>
</ul>
</div>
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<h1 title="Class Model" class="title">Class Model</h1>
</div>
<div class="contentContainer">
<div class="inheritance" title="Inheritance Tree">java.lang.Object
<div class="inheritance">Model</div>
</div>
<section class="description">
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="View.html" title="class in &lt;Unnamed&gt;">View</a></code></dd>
</dl>
<hr>
<pre>public class <span class="typeNameLabel">Model</span>
extends java.lang.Object</pre>
<div class="block">this class keep data</div>
</section>
<section class="summary">
<ul class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li class="blockList">
<section class="constructorSummary"><a id="constructor.summary">
<!-- -->
</a>
<h2>Constructor Summary</h2>
<div class="memberSummary">
<table>
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<thead>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Model</a></span>()</code></th>
<td class="colLast">
<div class="block">creat a new Model - set default values</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li class="blockList">
<section class="methodSummary"><a id="method.summary">
<!-- -->
</a>
<h2>Method Summary</h2>
<div class="inheritedList">
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a><code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li class="blockList">
<section class="constructorDetails"><a id="constructor.detail">
<!-- -->
</a>
<h2>Constructor Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="&lt;init&gt;()">Model</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="memberName">Model</span>()</div>
<div class="block">creat a new Model - set default values</div>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="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-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<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>Method</li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
</footer>
</body>
</html>
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>View</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="declaration: class: View">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="script-dir/jquery-ui.js"></script>
</head>
<body class="class-declaration">
<script type="text/javascript">var data = {"i0":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "./";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="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-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<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>
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<h1 title="Class View" class="title">Class View</h1>
</div>
<div class="contentContainer">
<div class="inheritance" title="Inheritance Tree">java.lang.Object
<div class="inheritance"><a href="Model.html" title="class in &lt;Unnamed&gt;">Model</a>
<div class="inheritance">View</div>
</div>
</div>
<section class="description">
<hr>
<pre>public class <span class="typeNameLabel">View</span>
extends <a href="Model.html" title="class in &lt;Unnamed&gt;">Model</a></pre>
<div class="block">this class present a Calculator GUI</div>
</section>
<section class="summary">
<ul class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li class="blockList">
<section class="constructorSummary"><a id="constructor.summary">
<!-- -->
</a>
<h2>Constructor Summary</h2>
<div class="memberSummary">
<table>
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<thead>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">View</a></span>()</code></th>
<td class="colLast">
<div class="block">creat a new Calculator</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li class="blockList">
<section class="methodSummary"><a id="method.summary">
<!-- -->
</a>
<h2>Method Summary</h2>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>java.lang.String</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#operation()">operation</a></span>()</code></th>
<td class="colLast">
<div class="block">this method calculate - for each operation</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="inheritedList">
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a><code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li class="blockList">
<section class="constructorDetails"><a id="constructor.detail">
<!-- -->
</a>
<h2>Constructor Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="&lt;init&gt;()">View</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="memberName">View</span>()</div>
<div class="block">creat a new Calculator</div>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li class="blockList">
<section class="methodDetails"><a id="method.detail">
<!-- -->
</a>
<h2>Method Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="operation()">operation</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">java.lang.String</span>&nbsp;<span class="memberName">operation</span>()</div>
<div class="block">this method calculate - for each operation</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>String of result</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="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-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<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>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
</footer>
</body>
</html>
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>All Classes</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="class index">
<meta name="generator" content="javadoc/AllClassesIndexWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......@@ -79,15 +79,21 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
</thead>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><a href="Calculator.html" title="class in &lt;Unnamed&gt;">Calculator</a></td>
<td class="colFirst"><a href="Main.html" title="class in &lt;Unnamed&gt;">Main</a></td>
<th class="colLast" scope="row">
<div class="block">this class present a Calculator GUI</div>
<div class="block">this class run calculator</div>
</th>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><a href="Main.html" title="class in &lt;Unnamed&gt;">Main</a></td>
<td class="colFirst"><a href="Model.html" title="class in &lt;Unnamed&gt;">Model</a></td>
<th class="colLast" scope="row">
<div class="block">this class run calculator</div>
<div class="block">this class keep data</div>
</th>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><a href="View.html" title="class in &lt;Unnamed&gt;">View</a></td>
<th class="colLast" scope="row">
<div class="block">this class present a Calculator GUI</div>
</th>
</tr>
</tbody>
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>All Packages</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="package index">
<meta name="generator" content="javadoc/AllPackagesIndexWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Constant Field Values</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="summary of constants">
<meta name="generator" content="javadoc/ConstantsSummaryWriterImpl">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Deprecated List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="deprecated elements">
<meta name="generator" content="javadoc/DeprecatedListWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>API Help</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="help">
<meta name="generator" content="javadoc/HelpWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......
......@@ -2,11 +2,11 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<title>C-Index</title>
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>M-Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="description" content="index: C">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="index: M">
<meta name="generator" content="javadoc/SplitIndexWriter">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../script-dir/jquery-ui.css" title="Style">
......@@ -67,21 +67,29 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
<div class="header">
<h1>Index</h1>
</div>
<div class="contentContainer"><a href="index-1.html">C</a>&nbsp;<a href="index-2.html">M</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a><a id="I:C">
<div class="contentContainer"><a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a><a id="I:M">
<!-- -->
</a>
<h2 class="title">C</h2>
<h2 class="title">M</h2>
<dl>
<dt><a href="../Calculator.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Calculator</span></a> - Class in <a href="../package-summary.html">&lt;Unnamed&gt;</a></dt>
<dt><span class="memberNameLink"><a href="../Main.html#main(java.lang.String%5B%5D)">main(String[])</a></span> - Static method in class <a href="../Main.html" title="class in &lt;Unnamed&gt;">Main</a></dt>
<dd>&nbsp;</dd>
<dt><a href="../Main.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Main</span></a> - Class in <a href="../package-summary.html">&lt;Unnamed&gt;</a></dt>
<dd>
<div class="block">this class present a Calculator GUI</div>
<div class="block">this class run calculator</div>
</dd>
<dt><span class="memberNameLink"><a href="../Calculator.html#%3Cinit%3E()">Calculator()</a></span> - Constructor for class <a href="../Calculator.html" title="class in &lt;Unnamed&gt;">Calculator</a></dt>
<dt><span class="memberNameLink"><a href="../Main.html#%3Cinit%3E()">Main()</a></span> - Constructor for class <a href="../Main.html" title="class in &lt;Unnamed&gt;">Main</a></dt>
<dd>&nbsp;</dd>
<dt><a href="../Model.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Model</span></a> - Class in <a href="../package-summary.html">&lt;Unnamed&gt;</a></dt>
<dd>
<div class="block">creat a new Calculator</div>
<div class="block">this class keep data</div>
</dd>
<dt><span class="memberNameLink"><a href="../Model.html#%3Cinit%3E()">Model()</a></span> - Constructor for class <a href="../Model.html" title="class in &lt;Unnamed&gt;">Model</a></dt>
<dd>
<div class="block">creat a new Model - set default values</div>
</dd>
</dl>
<a href="index-1.html">C</a>&nbsp;<a href="index-2.html">M</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>
<a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>
</main>
<footer role="contentinfo">
<nav role="navigation">
......
......@@ -2,11 +2,11 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<title>M-Index</title>
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>O-Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="description" content="index: M">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="index: O">
<meta name="generator" content="javadoc/SplitIndexWriter">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../script-dir/jquery-ui.css" title="Style">
......@@ -67,21 +67,17 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
<div class="header">
<h1>Index</h1>
</div>
<div class="contentContainer"><a href="index-1.html">C</a>&nbsp;<a href="index-2.html">M</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a><a id="I:M">
<div class="contentContainer"><a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a><a id="I:O">
<!-- -->
</a>
<h2 class="title">M</h2>
<h2 class="title">O</h2>
<dl>
<dt><span class="memberNameLink"><a href="../Main.html#main(java.lang.String%5B%5D)">main(String[])</a></span> - Static method in class <a href="../Main.html" title="class in &lt;Unnamed&gt;">Main</a></dt>
<dd>&nbsp;</dd>
<dt><a href="../Main.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Main</span></a> - Class in <a href="../package-summary.html">&lt;Unnamed&gt;</a></dt>
<dt><span class="memberNameLink"><a href="../View.html#operation()">operation()</a></span> - Method in class <a href="../View.html" title="class in &lt;Unnamed&gt;">View</a></dt>
<dd>
<div class="block">this class run calculator</div>
<div class="block">this method calculate - for each operation</div>
</dd>
<dt><span class="memberNameLink"><a href="../Main.html#%3Cinit%3E()">Main()</a></span> - Constructor for class <a href="../Main.html" title="class in &lt;Unnamed&gt;">Main</a></dt>
<dd>&nbsp;</dd>
</dl>
<a href="index-1.html">C</a>&nbsp;<a href="index-2.html">M</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>
<a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>
</main>
<footer role="contentinfo">
<nav role="navigation">
......
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>V-Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="index: V">
<meta name="generator" content="javadoc/SplitIndexWriter">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="../script.js"></script>
<script type="text/javascript" src="../script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../script-dir/jquery-ui.js"></script>
</head>
<body class="split-index">
<script type="text/javascript">var pathtoroot = "../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="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">
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<main role="main">
<div class="header">
<h1>Index</h1>
</div>
<div class="contentContainer"><a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a><a id="I:V">
<!-- -->
</a>
<h2 class="title">V</h2>
<dl>
<dt><a href="../View.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">View</span></a> - Class in <a href="../package-summary.html">&lt;Unnamed&gt;</a></dt>
<dd>
<div class="block">this class present a Calculator GUI</div>
</dd>
<dt><span class="memberNameLink"><a href="../View.html#%3Cinit%3E()">View()</a></span> - Constructor for class <a href="../View.html" title="class in &lt;Unnamed&gt;">View</a></dt>
<dd>
<div class="block">creat a new Calculator</div>
</dd>
</dl>
<a href="index-1.html">M</a>&nbsp;<a href="index-2.html">O</a>&nbsp;<a href="index-3.html">V</a>&nbsp;<br><a href="../allclasses-index.html">All&nbsp;Classes</a>&nbsp;<a href="../allpackages-index.html">All&nbsp;Packages</a></div>
</main>
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="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>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
</footer>
</body>
</html>
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Generated Documentation (Untitled)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="index redirect">
<meta name="generator" content="javadoc/IndexRedirectWriter">
<link rel="canonical" href="Main.html">
......
memberSearchIndex = [{"p":"<Unnamed>","c":"Calculator","l":"Calculator()","url":"%3Cinit%3E()"},{"p":"<Unnamed>","c":"Main","l":"Main()","url":"%3Cinit%3E()"},{"p":"<Unnamed>","c":"Main","l":"main(String[])","url":"main(java.lang.String[])"}]
\ No newline at end of file
memberSearchIndex = [{"p":"<Unnamed>","c":"Main","l":"Main()","url":"%3Cinit%3E()"},{"p":"<Unnamed>","c":"Main","l":"main(String[])","url":"main(java.lang.String[])"},{"p":"<Unnamed>","c":"Model","l":"Model()","url":"%3Cinit%3E()"},{"p":"<Unnamed>","c":"View","l":"operation()"},{"p":"<Unnamed>","c":"View","l":"View()","url":"%3Cinit%3E()"}]
\ No newline at end of file
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>Class Hierarchy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="class tree">
<meta name="generator" content="javadoc/TreeWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......@@ -73,8 +73,12 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
<ul>
<li class="circle">java.lang.Object
<ul>
<li class="circle"><a href="Calculator.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Calculator</span></a></li>
<li class="circle"><a href="Main.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Main</span></a></li>
<li class="circle"><a href="Model.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Model</span></a>
<ul>
<li class="circle"><a href="View.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">View</span></a></li>
</ul>
</li>
</ul>
</li>
</ul>
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title>&lt;Unnamed&gt;</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="declaration: package: &lt;unnamed&gt;">
<meta name="generator" content="javadoc/PackageWriterImpl">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......@@ -82,15 +82,21 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
</thead>
<tbody>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="Calculator.html" title="class in &lt;Unnamed&gt;">Calculator</a></th>
<th class="colFirst" scope="row"><a href="Main.html" title="class in &lt;Unnamed&gt;">Main</a></th>
<td class="colLast">
<div class="block">this class present a Calculator GUI</div>
<div class="block">this class run calculator</div>
</td>
</tr>
<tr class="rowColor">
<th class="colFirst" scope="row"><a href="Main.html" title="class in &lt;Unnamed&gt;">Main</a></th>
<th class="colFirst" scope="row"><a href="Model.html" title="class in &lt;Unnamed&gt;">Model</a></th>
<td class="colLast">
<div class="block">this class run calculator</div>
<div class="block">this class keep data</div>
</td>
</tr>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="View.html" title="class in &lt;Unnamed&gt;">View</a></th>
<td class="colLast">
<div class="block">this class present a Calculator GUI</div>
</td>
</tr>
</tbody>
......
......@@ -2,10 +2,10 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (13.0.2) on Thu Apr 30 18:11:38 IRDT 2020 -->
<!-- Generated by javadoc (13.0.2) on Wed May 06 19:49:07 IRDT 2020 -->
<title> Class Hierarchy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2020-04-30">
<meta name="dc.created" content="2020-05-06">
<meta name="description" content="tree: package: &lt;unnamed&gt;">
<meta name="generator" content="javadoc/PackageTreeWriter">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
......@@ -73,8 +73,12 @@ $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
<ul>
<li class="circle">java.lang.Object
<ul>
<li class="circle"><a href="Calculator.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Calculator</span></a></li>
<li class="circle"><a href="Main.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Main</span></a></li>
<li class="circle"><a href="Model.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">Model</span></a>
<ul>
<li class="circle"><a href="View.html" title="class in &lt;Unnamed&gt;"><span class="typeNameLink">View</span></a></li>
</ul>
</li>
</ul>
</li>
</ul>
......
typeSearchIndex = [{"l":"All Classes","url":"allclasses-index.html"},{"p":"<Unnamed>","l":"Calculator"},{"p":"<Unnamed>","l":"Main"}]
\ No newline at end of file
typeSearchIndex = [{"l":"All Classes","url":"allclasses-index.html"},{"p":"<Unnamed>","l":"Main"},{"p":"<Unnamed>","l":"Model"},{"p":"<Unnamed>","l":"View"}]
\ No newline at end of file
File added
import javax.swing.*;
import java.awt.*;
/**
* this class present a Calculator GUI
* @author Narges Salehi
*/
public class Calculator {
//creat a new JFrame for calculator frame
JFrame calcFrame;
/**
* creat a new Calculator
*/
public Calculator() {
//new JFrame
calcFrame = new JFrame("AUTCalculator");
//set size for frame
calcFrame.setSize(400, 500);
//set location of frame in your screen
calcFrame.setLocation(550, 250);
//make window not resizable
calcFrame.setResizable(false);
//set a layout for calculator
calcFrame.setLayout(new GridLayout(2,0,0,0));
calcFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//make window visible
calcFrame.setVisible(true);
//creat a new JPanel for standard calculator
JPanel p1 = new JPanel();
//set a layout for panel
p1.setLayout(new GridLayout(5, 4));
//creat a new JPanel for scientific calculator
JPanel p2 = new JPanel();
//set a layout for panel
p2.setLayout(new GridLayout(5, 5));
//creat a tab to add panels
JTabbedPane Calc = new JTabbedPane();
//set bounds of tab
Calc.setBounds(0, 100, 400, 380);
//add panels to tab
Calc.add("Standard", p1);
Calc.add("Scientific", p2);
//creat a text area for showing result
JTextArea display = new JTextArea();
//make possible to write in text area
display.setEditable(true);
//set font size and type of words in text area
display.setFont(new Font("Arial", Font.BOLD, 14));
//creat a scroll for text area
JScrollPane scrollPane = new JScrollPane(display);
//make scroll for both horizontal and vertical
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//add scroll to frame
calcFrame.getContentPane().add(scrollPane);
//creating and adding buttons to each calculator
JButton openBot = new JButton("(");
p1.add(openBot);
JButton closeBot = new JButton(")");
p1.add(closeBot);
JButton remBot = new JButton("%");
p1.add(remBot);
JButton clearBot = new JButton("C");
p1.add(clearBot);
JButton seven = new JButton("7");
p1.add(seven);
JButton eight = new JButton("8");
p1.add(eight);
JButton nine = new JButton("9");
p1.add(nine);
JButton divBot = new JButton("/");
p1.add(divBot);
JButton four = new JButton("4");
p1.add(four);
JButton five = new JButton("5");
p1.add(five);
JButton six = new JButton("6");
p1.add(six);
JButton mulBot = new JButton("*");
p1.add(mulBot);
JButton one = new JButton("1");
p1.add(one);
JButton two = new JButton("2");
p1.add(two);
JButton three = new JButton("3");
p1.add(three);
JButton subBot = new JButton("-");
p1.add(subBot);
JButton zeroBtn = new JButton("0");
p1.add(zeroBtn);
JButton dot = new JButton(".");
p1.add(dot);
JButton doBtn = new JButton("=");
p1.add(doBtn);
JButton sumBtn = new JButton("+");
p1.add(sumBtn);
//adding and creating buttons for scientific calculator
//extra button of scientific calculator
JButton eOrEuler = new JButton("e-π");
JButton shift = new JButton("Shift");
JButton sinOrCos = new JButton("sin-cos");
JButton tanOrCot = new JButton("tan-cot");
JButton expOrLog = new JButton("exp-log");
p2.add(shift);
JButton openBot2 = new JButton("(");
p2.add(openBot2);
JButton closeBot2 = new JButton(")");
p2.add(closeBot2);
JButton remBot2 = new JButton("%");
p2.add(remBot2);
JButton clearBot2 = new JButton("C");
p2.add(clearBot2);
p2.add(eOrEuler);
JButton seven2 = new JButton("7");
p2.add(seven2);
JButton eight2 = new JButton("8");
p2.add(eight2);
JButton nine2 = new JButton("9");
p2.add(nine2);
JButton divBot2 = new JButton("/");
p2.add(divBot2);
p2.add(tanOrCot);
JButton four2 = new JButton("4");
p2.add(four2);
JButton five2 = new JButton("5");
p2.add(five2);
JButton six2 = new JButton("6");
p2.add(six2);
JButton mulBot2 = new JButton("*");
p2.add(mulBot2);
p2.add(expOrLog);
JButton one2 = new JButton("1");
p2.add(one2);
JButton two2 = new JButton("2");
p2.add(two2);
JButton three2 = new JButton("3");
p2.add(three2);
JButton subBot2 = new JButton("-");
p2.add(subBot2);
p2.add(sinOrCos);
JButton zeroBtn2 = new JButton("0");
p2.add(zeroBtn2);
JButton dot2 = new JButton(".");
p2.add(dot2);
JButton doBtn2 = new JButton("=");
p2.add(doBtn2);
JButton sumBtn2 = new JButton("+");
p2.add(sumBtn2);
//add tab to frame
calcFrame.add(Calc);
}
}
\ No newline at end of file
......@@ -7,13 +7,13 @@ import javax.swing.*;
public class Main {
public static void main(String[] args) {
for(UIManager.LookAndFeelInfo info :UIManager.getInstalledLookAndFeels())
System.out.println(info.getClassName());
//
// for(UIManager.LookAndFeelInfo info :UIManager.getInstalledLookAndFeels())
// System.out.println(info.getClassName());
//choosing UI
try {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Motif".equals(info.getName())) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
......@@ -22,6 +22,7 @@ public class Main {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
//creat a new calculator
Calculator calculator = new Calculator();
View view =new View();
}
}
import java.security.PublicKey;
import java.util.ArrayList;
/**
* this class keep data
* @author Narges Salehi
*/
public class Model {
//this array list keep numbers
ArrayList<Double> numbers;
//this array list keep operations
ArrayList<Character> operations;
//result
double result;
//index of numbers
int indexOfNum;
//index of operations
int indexOfOpe;
//keep result as a String
String text ;
//keep true for first digit of each number
boolean firstTime;
//keep true for new numbers begin
boolean hasOperation;
//check if shift has pressed
int shiftfalg;
/**
* creat a new Model - set default values
*/
public Model(){
numbers=new ArrayList<Double>();
operations=new ArrayList<Character>();
result=0;
indexOfNum=0;
indexOfOpe=0;
text="";
firstTime=true;
hasOperation=false;
shiftfalg=0;
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
/**
* this class present a Calculator GUI
*
* @author Narges Salehi
*/
public class View extends Model {
//creat a new JFrame for calculator frame
JFrame window;
//creat a new JPanel for standard calculator
JPanel p1 = new JPanel();
//creat a new JPanel for scientific calculator
JPanel p2 = new JPanel();
//creat a tab to add panels
JTabbedPane Switch = new JTabbedPane();
//creat a text area for showing result
JTextArea display = new JTextArea();
//an item for exit program
JMenuItem exit;
//am item to copy what is in text area
JMenuItem copy;
//Buttons
JButton openBot = new JButton("(");
JButton closeBot = new JButton(")");
JButton remBot = new JButton("%");
JButton clearBot = new JButton("C");
JButton seven = new JButton("7");
JButton eight = new JButton("8");
JButton nine = new JButton("9");
JButton divBot = new JButton("/");
JButton four = new JButton("4");
JButton five = new JButton("5");
JButton six = new JButton("6");
JButton mulBot = new JButton("*");
JButton one = new JButton("1");
JButton two = new JButton("2");
JButton three = new JButton("3");
JButton subBot = new JButton("-");
JButton zeroBtn = new JButton("0");
JButton dot = new JButton(".");
JButton equalBtn = new JButton("=");
JButton sumBtn = new JButton("+");
//extra button of scientific calculator
JButton eOrEuler = new JButton("e-π");
JButton shift = new JButton("Shift");
JButton sinOrCos = new JButton("sin-cos");
JButton tanOrCot = new JButton("tan-cot");
JButton expOrLog = new JButton("exp-log");
JButton openBot2 = new JButton("(");
JButton closeBot2 = new JButton(")");
JButton remBot2 = new JButton("%");
JButton clearBot2 = new JButton("C");
JButton seven2 = new JButton("7");
JButton eight2 = new JButton("8");
JButton nine2 = new JButton("9");
JButton divBot2 = new JButton("/");
JButton four2 = new JButton("4");
JButton five2 = new JButton("5");
JButton six2 = new JButton("6");
JButton mulBot2 = new JButton("*");
JButton one2 = new JButton("1");
JButton two2 = new JButton("2");
JButton three2 = new JButton("3");
JButton subBot2 = new JButton("-");
JButton zeroBtn2 = new JButton("0");
JButton equalBtn2 = new JButton("=");
JButton sumBtn2 = new JButton("+");
JButton dot2 = new JButton(".");
/**
* creat a new Calculator
*/
public View() {
super();
//new JFrame
window = new JFrame("AUTCalculator");
//set size for frame
window.setSize(400, 500);
//set location of frame in your screen
window.setLocation(550, 250);
//make window not resizable
window.setResizable(false);
//set a layout for calculator
window.setLayout(new GridBagLayout());
//set location of first component
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.NORTHWEST;
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//creat a JMenuBar
JMenuBar jMenuBar = new JMenuBar();
//creat a JMenu
JMenu jMenu = new JMenu("File");
//set a mnemonic Alt+f
jMenu.setMnemonic('f');
//creat Item for menu
exit = new JMenuItem("Exit");
copy = new JMenuItem("Copy");
//set accelerator for items
exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.SHIFT_MASK));
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.SHIFT_MASK));
//creat a new handler for JMenuBar
jMenuHandler jMenuHandler = new jMenuHandler();
//add handler to items
exit.addActionListener(jMenuHandler);
copy.addActionListener(jMenuHandler);
//add items to JMenu
jMenu.add(exit);
jMenu.add(copy);
//add menu to JMenuBar
jMenuBar.add(jMenu);
//add JMenuBar to JFrame with given gbc
window.add(jMenuBar, gbc);
//make window visible
window.setVisible(true);
//set a layout for panel
p1.setLayout(new GridLayout(5, 4));
//set a layout for panel
p2.setLayout(new GridLayout(5, 5));
//set bounds of tab
Switch.setBounds(0, 100, 400, 380);
//add panels to tab
Switch.add("Standard", p1);
Switch.add("Scientific", p2);
//make not possible to write in text area
display.setEditable(false);
display.setPreferredSize(new Dimension(0, 10));
display.setToolTipText("Display");
//set font size and type of words in text area
display.setFont(new Font("Arial", Font.BOLD, 14));
//make scroll for both horizontal and vertical
//creat a scroll for text area
JScrollPane scrollPane = new JScrollPane(display);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//add scroll to frame
//set location fot second component
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1;
gbc.weighty = 2;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.NORTHWEST;
window.getContentPane().add(scrollPane, gbc);
//creat a new handler for buttons
ButtonClickHandler handler = new ButtonClickHandler();
//creating and adding buttons to each calculator - adding handler to buttons - also set tool tip text
p1.add(openBot);
openBot.addActionListener(handler);
openBot.setToolTipText("Parentheses");
p1.add(closeBot);
closeBot.setToolTipText("Parentheses");
closeBot.addActionListener(handler);
p1.add(remBot);
remBot.setToolTipText("Remaining");
remBot.addActionListener(handler);
p1.add(clearBot);
clearBot.setToolTipText("Clear");
clearBot.addActionListener(handler);
p1.add(seven);
seven.setToolTipText("Number 7");
seven.addActionListener(handler);
p1.add(eight);
eight.setToolTipText("Number 8");
eight.addActionListener(handler);
p1.add(nine);
nine.setToolTipText("Number 9");
nine.addActionListener(handler);
p1.add(divBot);
divBot.setToolTipText("Division");
divBot.addActionListener(handler);
p1.add(four);
four.setToolTipText("Number 4");
four.addActionListener(handler);
p1.add(five);
five.setToolTipText("number 5");
five.addActionListener(handler);
p1.add(six);
six.setToolTipText("Number 6");
six.addActionListener(handler);
p1.add(mulBot);
mulBot.setToolTipText("Multiplier");
mulBot.addActionListener(handler);
p1.add(one);
one.setToolTipText("Number 1");
one.addActionListener(handler);
p1.add(two);
two.setToolTipText("Number 2");
two.addActionListener(handler);
p1.add(three);
three.setToolTipText("Number 3");
three.addActionListener(handler);
p1.add(subBot);
subBot.setToolTipText("Subtraction");
subBot.addActionListener(handler);
p1.add(zeroBtn);
zeroBtn.setToolTipText("Number 0");
zeroBtn.addActionListener(handler);
p1.add(dot);
dot.setToolTipText("Dot");
dot.addActionListener(handler);
p1.add(equalBtn);
equalBtn.setToolTipText("Equal");
equalBtn.addActionListener(handler);
p1.add(sumBtn);
sumBtn.setToolTipText("Sub");
sumBtn.addActionListener(handler);
//adding and creating buttons for scientific calculator
p2.add(shift);
shift.setToolTipText("Shift");
shift.addActionListener(handler);
p2.add(openBot2);
openBot2.addActionListener(handler);
p2.add(closeBot2);
closeBot2.addActionListener(handler);
p2.add(remBot2);
remBot2.addActionListener(handler);
p2.add(clearBot2);
clearBot2.addActionListener(handler);
p2.add(eOrEuler);
eOrEuler.addActionListener(handler);
p2.add(seven2);
seven2.addActionListener(handler);
p2.add(eight2);
eight2.addActionListener(handler);
p2.add(nine2);
nine2.addActionListener(handler);
p2.add(divBot2);
divBot2.addActionListener(handler);
p2.add(tanOrCot);
tanOrCot.addActionListener(handler);
p2.add(four2);
four2.addActionListener(handler);
p2.add(five2);
five2.addActionListener(handler);
p2.add(six2);
six2.addActionListener(handler);
p2.add(mulBot2);
mulBot2.addActionListener(handler);
p2.add(expOrLog);
expOrLog.addActionListener(handler);
p2.add(one2);
one2.addActionListener(handler);
p2.add(two2);
two2.addActionListener(handler);
p2.add(three2);
three2.addActionListener(handler);
p2.add(subBot2);
subBot2.addActionListener(handler);
p2.add(sinOrCos);
sinOrCos.addActionListener(handler);
p2.add(zeroBtn2);
zeroBtn2.addActionListener(handler);
p2.add(dot2);
dot2.addActionListener(handler);
p2.add(equalBtn2);
equalBtn2.addActionListener(handler);
p2.add(sumBtn2);
sumBtn2.addActionListener(handler);
//add tab to frame with new location
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1;
gbc.weighty = 7;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.NORTHWEST;
window.add(Switch, gbc);
//make text area focused
display.requestFocusInWindow();
display.setFocusable(true);
//creat a new handler
ButtonKeyboardHandler handler1 = new ButtonKeyboardHandler();
//add handler to text area
display.addKeyListener(handler1);
}
/**
* this class manage buttons on Calculator
*/
private class ButtonClickHandler implements ActionListener {
@Override
/**
* perform each button action
*/
public void actionPerformed(ActionEvent e) {
//check if button 1 has pressed
if (e.getSource().equals(one) || e.getSource().equals(one2)) {
//check if an operator has pressed befor
if (hasOperation) {
//make text area empty for new number
display.setText("");
//make hasOperation Boolean false
hasOperation = false;
}
//check if its first digit of number - handel out of bounds exception
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
//this double keep numbers value
Double temp = numbers.get(indexOfNum) * 10 + 1;
//update number and add it again
numbers.add(indexOfNum, temp);
//show number on text area
display.setText(String.valueOf(temp));
//same as before fot all other buttons
} else if (e.getSource().equals(two) || e.getSource().equals(two2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
Double temp = numbers.get(indexOfNum) * 10 + 2;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(three) || e.getSource().equals(three2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 3;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(four) || e.getSource().equals(four2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 4;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(five) || e.getSource().equals(five2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 5;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(six) || e.getSource().equals(six2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 6;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(seven) || e.getSource().equals(seven2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 7;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(eight) || e.getSource().equals(eight2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 8;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(nine) || e.getSource().equals(nine2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10 + 9;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(zeroBtn) || e.getSource().equals(zeroBtn2)) {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
} else if (e.getSource().equals(shift)) {
if (shiftfalg == 0)
shiftfalg = 1;
else
shiftfalg = 0;
}
//check if we can add operator - at least one number has added
else if (numbers.size() != 0) {
//check if its sum button
if (e.getSource().equals(sumBtn) || e.getSource().equals(sumBtn2)) {
//count index of number - next number is a new number
indexOfNum++;
//next digit is first digit
firstTime = true;
//it has operation before
hasOperation = true;
//add operation
operations.add('+');
}
//same for other operation buttons
else if (e.getSource().equals(subBot) || e.getSource().equals(subBot2)) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('-');
} else if (e.getSource().equals(divBot) || e.getSource().equals(divBot2)) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('/');
} else if (e.getSource().equals(remBot) || e.getSource().equals(remBot2)) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('%');
} else if (e.getSource().equals(mulBot) || e.getSource().equals(mulBot2)) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('*');
System.out.println(operations);
} else if (e.getSource().equals(sinOrCos)) {
if (shiftfalg == 0)
operations.add('s');
else {
operations.add('c');
}
indexOfNum++;
firstTime = true;
hasOperation = true;
} else if (e.getSource().equals(equalBtn) || e.getSource().equals(equalBtn2)) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('=');
display.setText(operation());
//after counting result call Model class constructor to reset data
numbers = new ArrayList<Double>();
operations = new ArrayList<Character>();
result = 0;
indexOfNum = 0;
indexOfOpe = 0;
text = "";
firstTime = true;
hasOperation = false;
}
}
}
}
/**
* manage buttons on JMenu
*/
private class jMenuHandler implements ActionListener {
@Override
/**
* perform JItem actions
*/
public void actionPerformed(ActionEvent e) {
//exit item exit program
if (e.getSource().equals(exit)) {
System.exit(0);
}
//copy text area content
if (e.getSource().equals(copy)) {
display.selectAll();
display.copy();
}
}
}
/**
* manage keyboard event
*/
private class ButtonKeyboardHandler implements KeyListener {
//this boolean check if shift button has pressed
boolean Shift;
@Override
public void keyTyped(KeyEvent e) {
}
@Override
/*
check which button has pressed
*/
public void keyPressed(KeyEvent e) {
//get event keyCode
int keyCode = e.getKeyCode();
//do for each case - like action listener
switch (keyCode) {
case KeyEvent.VK_SHIFT:
Shift = true;
break;
case KeyEvent.VK_0:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
double temp = numbers.get(indexOfNum) * 10;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_1:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 1;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_2:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 2;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_3:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 3;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_4:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 4;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_5:
if (Shift) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('%');
Shift = false;
break;
} else {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 5;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
}
case KeyEvent.VK_6:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 6;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_7:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 7;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_8:
if (Shift) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('*');
Shift = false;
break;
} else {
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 8;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
}
case KeyEvent.VK_9:
if (hasOperation) {
display.setText("");
hasOperation = false;
}
if (firstTime) {
numbers.add(indexOfNum, 0.0);
firstTime = false;
}
temp = numbers.get(indexOfNum) * 10 + 9;
numbers.add(indexOfNum, temp);
display.setText(String.valueOf(temp));
break;
case KeyEvent.VK_MINUS:
System.out.println("k");
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('-');
break;
case KeyEvent.VK_SLASH:
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('/');
break;
case KeyEvent.VK_EQUALS:
if (Shift) {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('+');
Shift = false;
break;
} else {
indexOfNum++;
firstTime = true;
hasOperation = true;
operations.add('=');
display.setText(operation());
numbers = new ArrayList<Double>();
operations = new ArrayList<Character>();
result = 0;
indexOfNum = 0;
indexOfOpe = 0;
text = "";
firstTime = true;
hasOperation = false;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
/**
* this method calculate - for each operation
*
* @return String of result
*/
public String operation() {
//for first and second number check first operation
if (operations.get(0).equals('+'))
result = numbers.get(0) + numbers.get(1);
if (operations.get(0).equals('-'))
result = numbers.get(0) - numbers.get(1);
if (operations.get(0).equals('*'))
result = numbers.get(0) * numbers.get(1);
if (operations.get(0).equals('/')) {
result = numbers.get(0) / numbers.get(1);
}
if (operations.get(0).equals('%'))
result = numbers.get(0) % numbers.get(1);
indexOfNum = 2;
indexOfOpe = 1;
if (operations.get(0).equals('s')) {
if (numbers.get(0) % 180 == 0) {
result = Math.toRadians(numbers.get(0));
result = Math.round(Math.sin(result));
indexOfNum = 1;
indexOfOpe = 1;
} else {
result = Math.toRadians(numbers.get(0));
result = Math.sin(result);
indexOfNum = 1;
indexOfOpe = 1;
}
}
if (operations.get(0).equals('c')) {
if (numbers.get(0) % 90 == 0) {
result = Math.toRadians(numbers.get(0));
result = Math.round(Math.cos(result));
indexOfNum = 1;
indexOfOpe = 1;
} else {
result = Math.toRadians(numbers.get(0));
result = Math.cos(result);
indexOfNum = 1;
indexOfOpe = 1;
}
}
//for the rest number
while (indexOfOpe < operations.size()) {
if (operations.get(indexOfOpe) == '+') {
result += numbers.get(indexOfNum);
} else if (operations.get(indexOfOpe) == '-') {
result -= numbers.get(indexOfNum);
} else if (operations.get(indexOfOpe) == '*') {
result *= numbers.get(indexOfNum);
} else if (operations.get(indexOfOpe) == '/') {
result /= numbers.get(indexOfNum);
} else if (operations.get(indexOfOpe) == '%') {
result %= numbers.get(indexOfNum);
} else if (operations.get(indexOfOpe) == '=') {
String str = String.valueOf(result);
return str;
} else if (operations.get(indexOfOpe) == 's') {
result = Math.toRadians(result);
result = Math.sin(result);
} else if (operations.get(indexOfOpe) == 'c') {
result = Math.toRadians(result);
result = Math.cos(result);
}
indexOfOpe++;
indexOfNum++;
}
String str = String.valueOf(result);
return str;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment