generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0d094
commit 19b832c
Showing
52 changed files
with
17,575 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1 id="this-is-my-first-post">This is my first post</h1> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"><head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="twitter:card" content="summary_large_image" /><!-- Begin Jekyll SEO tag v2.8.0 --> | ||
<title>Writing Classes | Sarayu</title> | ||
<meta name="generator" content="Jekyll v4.1.1" /> | ||
<meta property="og:title" content="Writing Classes" /> | ||
<meta property="og:locale" content="en_US" /> | ||
<meta name="description" content="Unit 5" /> | ||
<meta property="og:description" content="Unit 5" /> | ||
<link rel="canonical" href="https://sarayu-pr11.github.io/sarayucsa/2022/10/20/classes.html" /> | ||
<meta property="og:url" content="https://sarayu-pr11.github.io/sarayucsa/2022/10/20/classes.html" /> | ||
<meta property="og:site_name" content="Sarayu" /> | ||
<meta property="og:type" content="article" /> | ||
<meta property="article:published_time" content="2022-10-20T00:00:00-05:00" /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta property="twitter:title" content="Writing Classes" /> | ||
<script type="application/ld+json"> | ||
{"@context":"https://schema.org","@type":"BlogPosting","dateModified":"2022-10-20T00:00:00-05:00","datePublished":"2022-10-20T00:00:00-05:00","description":"Unit 5","headline":"Writing Classes","mainEntityOfPage":{"@type":"WebPage","@id":"https://sarayu-pr11.github.io/sarayucsa/2022/10/20/classes.html"},"url":"https://sarayu-pr11.github.io/sarayucsa/2022/10/20/classes.html"}</script> | ||
<!-- End Jekyll SEO tag --> | ||
<link rel="stylesheet" href="/sarayucsa/assets/css/style.css"><link type="application/atom+xml" rel="alternate" href="https://sarayu-pr11.github.io/sarayucsa/feed.xml" title="Sarayu" /><link rel="shortcut icon" type="image/x-icon" href="/sarayucsa/images/favicon.ico"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/15.2.0/primer.css" integrity="sha512-xTz2ys4coGAOz8vuV1NcQBkgVmKhsSEtjbqyMJbBHRplFuvKIUo6xhLHpAyPt9mfR6twHJgn9OgVLuqOvjeBhg==" crossorigin="anonymous" /> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" /> | ||
|
||
<script> | ||
function wrap_img(fn) { | ||
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") { | ||
var elements = document.querySelectorAll(".post img"); | ||
Array.prototype.forEach.call(elements, function(el, i) { | ||
if (el.getAttribute("title") && (el.className != "emoji")) { | ||
const caption = document.createElement('figcaption'); | ||
var node = document.createTextNode(el.getAttribute("title")); | ||
caption.appendChild(node); | ||
const wrapper = document.createElement('figure'); | ||
wrapper.className = 'image'; | ||
el.parentNode.insertBefore(wrapper, el); | ||
el.parentNode.removeChild(el); | ||
wrapper.appendChild(el); | ||
wrapper.appendChild(caption); | ||
} | ||
}); | ||
} else { document.addEventListener('DOMContentLoaded', fn); } | ||
} | ||
window.onload = wrap_img; | ||
</script> | ||
|
||
<script> | ||
document.addEventListener("DOMContentLoaded", function(){ | ||
// add link icon to anchor tags | ||
var elem = document.querySelectorAll(".anchor-link") | ||
elem.forEach(e => (e.innerHTML = '<i class="fas fa-link fa-xs"></i>')); | ||
}); | ||
</script> | ||
</head> | ||
<body><header class="site-header"> | ||
|
||
<div class="wrapper"><a class="site-title" rel="author" href="/sarayucsa/">Sarayu</a><nav class="site-nav"> | ||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> | ||
<label for="nav-trigger"> | ||
<span class="menu-icon"> | ||
<svg viewBox="0 0 18 15" width="18px" height="15px"> | ||
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/> | ||
</svg> | ||
</span> | ||
</label> | ||
|
||
<div class="trigger"><a class="page-link" href="/sarayucsa/_pages/01_homework.html">Homework and Notes</a><a class="page-link" href="/sarayucsa/about/">About Me</a><a class="page-link" href="/sarayucsa/reflection/">Reflection</a><a class="page-link" href="/sarayucsa/_pages/collegeboard.html">College Board Notes</a><a class="page-link" href="/sarayucsa/search/">Search</a><a class="page-link" href="/sarayucsa/categories/">Tags</a></div> | ||
</nav></div> | ||
</header> | ||
<main class="page-content" aria-label="Content"> | ||
<div class="wrapper"> | ||
<!-- | ||
################################################# | ||
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ### | ||
################################################# | ||
# file to edit: _notebooks/2022-10-20-classes.ipynb | ||
--> | ||
|
||
<div class="container" id="notebook-container"> | ||
|
||
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell"> | ||
<div class="text_cell_render border-box-sizing rendered_html"> | ||
<h1 id="Classes">Classes<a class="anchor-link" href="#Classes"> </a></h1><h2 id="Why-do-we-need-classes">Why do we need classes<a class="anchor-link" href="#Why-do-we-need-classes"> </a></h2><ul> | ||
<li>essential part of OOP | ||
models real world objects in code</li> | ||
</ul> | ||
<h2 id="Anatomy-of-a-java-Class">Anatomy of a java Class<a class="anchor-link" href="#Anatomy-of-a-java-Class"> </a></h2><ul> | ||
<li>object:<ul> | ||
<li>state attributes, behavior, </li> | ||
<li>instance of a class</li> | ||
<li>represented by an instance in the program</li> | ||
</ul> | ||
</li> | ||
<li>class<ul> | ||
<li>defines an abstract data tye</li> | ||
<li>string variables</li> | ||
<li>instance variables: attributes, behaviors</li> | ||
<li>data for objects</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<h2 id="Methods-and-Constructors">Methods and Constructors<a class="anchor-link" href="#Methods-and-Constructors"> </a></h2><ul> | ||
<li>methods are behaviors or actions that apply to the objects</li> | ||
<li>constructors create the object</li> | ||
<li>main method tests class and instance variables</li> | ||
</ul> | ||
<h2 id="Constructors">Constructors<a class="anchor-link" href="#Constructors"> </a></h2><ul> | ||
<li>special method for instantiation<ul> | ||
<li>sets initial values</li> | ||
</ul> | ||
</li> | ||
<li>default constructor</li> | ||
<li>can have multiple constructors per class</li> | ||
</ul> | ||
<h2 id="Documentation-with-Comments">Documentation with Comments<a class="anchor-link" href="#Documentation-with-Comments"> </a></h2><h3 id="Commenting">Commenting<a class="anchor-link" href="#Commenting"> </a></h3><ul> | ||
<li>comment with // for a single line</li> | ||
<li>multiple line or documentation comment</li> | ||
<li>helps explain code as you go</li> | ||
</ul> | ||
<h2 id="Accessor-and-Mutator-Methods">Accessor and Mutator Methods<a class="anchor-link" href="#Accessor-and-Mutator-Methods"> </a></h2><h3 id="Accessor-Methods">Accessor Methods<a class="anchor-link" href="#Accessor-Methods"> </a></h3><ul> | ||
<li>get of methods or getters</li> | ||
<li>allow you to get values or variable</li> | ||
<li>non void methods</li> | ||
<li>return a value of specified data type</li> | ||
</ul> | ||
<h3 id="Mutator-Methods">Mutator Methods<a class="anchor-link" href="#Mutator-Methods"> </a></h3><ul> | ||
<li>set of methods or setters</li> | ||
<li>void methods won't return values</li> | ||
</ul> | ||
<h2 id="Writing-Methods">Writing Methods<a class="anchor-link" href="#Writing-Methods"> </a></h2><ul> | ||
<li>method definition, method signature, method body</li> | ||
<li>camelCase </li> | ||
<li>Object.method() | ||
### Method Return Types</li> | ||
<li>string, int, bool, any object type, void (return no value)</li> | ||
</ul> | ||
<h2 id="Keywords-in-Java">Keywords in Java<a class="anchor-link" href="#Keywords-in-Java"> </a></h2><h3 id="Static-Modifier">Static Modifier<a class="anchor-link" href="#Static-Modifier"> </a></h3><ul> | ||
<li>key word usually used after access modifiers</li> | ||
<li>denotes as belonging to a class</li> | ||
<li>cannot reference static variables | ||
universally shared variables and methods among objects | ||
### This</li> | ||
<li>refers to the constructor that is being called in</li> | ||
<li>eliminated confusion between attribute and parameters | ||
### Access Modifiers</li> | ||
<li>restricts scope of classes variables and function</li> | ||
<li>used for encapsulation</li> | ||
<li>prevents misuse of data and methods</li> | ||
</ul> | ||
<h2 id="Scope-and-Access">Scope and Access<a class="anchor-link" href="#Scope-and-Access"> </a></h2><ul> | ||
<li>where a variable can be accessed or used</li> | ||
<li>declaration of variable</li> | ||
<li>3 levels<ul> | ||
<li>class level: instance var</li> | ||
<li>method level: local, parameter var</li> | ||
<li>block level: loops, if/else</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<p><a href="https://dontran15.github.io/CSAFastPages/college%20board/week%209/2022/10/18/java-test.html">Code Examples</a></p> | ||
<h2 id="Homework">Homework<a class="anchor-link" href="#Homework"> </a></h2><ul> | ||
<li>2021 FRQ 1a 3a</li> | ||
</ul> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<div class="cell border-box-sizing code_cell rendered"> | ||
<div class="input"> | ||
|
||
<div class="inner_cell"> | ||
<div class="input_area"> | ||
<div class=" highlight hl-java"><pre><span></span><span class="kd">public</span> <span class="kt">int</span> <span class="nf">scoreGuess</span> <span class="p">(</span><span class="n">String</span> <span class="n">guess</span><span class="p">)</span> | ||
<span class="kt">int</span> <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> | ||
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><=</span> <span class="n">secret</span><span class="p">.</span><span class="na">length</span><span class="p">()</span> <span class="o">-</span> <span class="n">guess</span><span class="p">.</span><span class="na">length</span><span class="p">();</span> <span class="n">i</span><span class="o">++</span><span class="p">){</span> | ||
<span class="k">if</span> <span class="p">(</span><span class="n">secret</span><span class="p">.</span><span class="na">substring</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">i</span> <span class="o">+</span> <span class="n">guess</span><span class="p">.</span><span class="na">length</span><span class="p">()).</span><span class="na">equals</span> <span class="p">(</span><span class="n">guess</span><span class="p">)){</span> | ||
<span class="n">count</span><span class="o">++</span><span class="p">;</span> | ||
<span class="p">}</span> | ||
<span class="p">}</span> | ||
<span class="k">return</span> <span class="n">count</span> <span class="o">*</span> <span class="n">guess</span><span class="p">.</span><span class="na">length</span><span class="p">()</span> <span class="o">*</span> <span class="n">guess</span><span class="p">.</span><span class="na">length</span><span class="p">();</span> | ||
|
||
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">addMembers</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">names</span><span class="p">,</span> <span class="kt">int</span> <span class="n">gradYear</span> <span class="p">){</span> | ||
|
||
<span class="k">for</span><span class="p">(</span> <span class="n">String</span> <span class="n">n</span> <span class="p">:</span> <span class="n">names</span> <span class="p">){</span> | ||
<span class="n">memberList</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="k">new</span> <span class="n">MemberInfo</span><span class="p">(</span> <span class="n">n</span><span class="p">,</span> <span class="n">gradYear</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span> <span class="p">);</span> | ||
<span class="p">}</span> | ||
<span class="p">}</span> | ||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
</div> | ||
|
||
|
||
|
||
</div> | ||
</main><footer class="site-footer h-card"> | ||
<data class="u-url" href="/sarayucsa/"></data> | ||
|
||
<div class="wrapper"> | ||
|
||
<div class="footer-col-wrapper"> | ||
<div class="footer-col"> | ||
<p class="feed-subscribe"> | ||
<a href="https://sarayu-pr11.github.io/sarayucsa/feed.xml"> | ||
<svg class="svg-icon orange"> | ||
<use xlink:href="/sarayucsa/assets/minima-social-icons.svg#rss"></use> | ||
</svg><span>Subscribe</span> | ||
</a> | ||
</p> | ||
</div> | ||
<div class="footer-col"> | ||
<p>An easy to use blogging platform with support for Jupyter Notebooks.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="social-links"><ul class="social-media-list"><li> | ||
<a rel="me" href="https://github.com/exampleUser" target="_blank" title="github"> | ||
<svg class="svg-icon grey"> | ||
<use xlink:href="/sarayucsa/assets/minima-social-icons.svg#github"></use> | ||
</svg> | ||
</a> | ||
</li> | ||
<li> | ||
<a rel="me" href="https://twitter.com/exampleUser" target="_blank" title="twitter"> | ||
<svg class="svg-icon grey"> | ||
<use xlink:href="/sarayucsa/assets/minima-social-icons.svg#twitter"></use> | ||
</svg> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
</div> | ||
|
||
</footer> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.