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
a738f9e
commit d8d9423
Showing
4 changed files
with
410 additions
and
16 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,160 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Test\n", | ||
"- toc: true \n", | ||
"- badges: true\n", | ||
"- comments: true\n", | ||
"- categories: [jupyter, FRQs]\n", | ||
"- image: images/chart-preview.png" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"1. Define 1 argument constructor for Java for book\n", | ||
"2. Define toString method for title, and a testor method\n", | ||
"3. Generate unique id for class\n", | ||
"4. Create a public getter that has a book count\n", | ||
"5. Define tester method that intializes st least 2 books, outputs id and title, and provides a count of books in library" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"public class Book\n", | ||
"{\n", | ||
" String = title; \n", | ||
" double = id; \n", | ||
" int = numberOfBooks;\n", | ||
" int1 = book1;\n", | ||
" int2 = book2;\n", | ||
"\n", | ||
" String () = booktitle;\n", | ||
" {\n", | ||
" public Book (title)\n", | ||
" {\n", | ||
" double bookCount = int1 + int2;\n", | ||
" this.get = bookCount;\n", | ||
"\n", | ||
" }\n", | ||
" \n", | ||
" public void toString \n", | ||
" {\n", | ||
" this.get = bookCount;\n", | ||
" this.generate \n", | ||
" }\n", | ||
" }\n", | ||
" System.out.println(\"There are two books in the library\");\n", | ||
" System.out.println(\"\")\n", | ||
" System.out.println(\"The number of books is\" +bookCount \"in the library\");\n", | ||
" return bookCount; \n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Part 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Title: Brave New World, ID: 1\n", | ||
"Title: Things Fall Apart, ID: 2\n", | ||
"Total number of books: 2\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"public class Book {\n", | ||
" private static int bookCount = 0;\n", | ||
" private int id;\n", | ||
" private String title;\n", | ||
" \n", | ||
" public Book(String title) {\n", | ||
" this.title = title;\n", | ||
" id = ++bookCount;\n", | ||
" }\n", | ||
" \n", | ||
" @Override\n", | ||
" public String toString() {\n", | ||
" return \"Title: \" + title;\n", | ||
" }\n", | ||
" \n", | ||
" public int getId() {\n", | ||
" return id;\n", | ||
" }\n", | ||
" \n", | ||
" public static int getBookCount() {\n", | ||
" return bookCount;\n", | ||
" }\n", | ||
" public static void main(String[] args) {\n", | ||
" Book book1 = new Book(\"Brave New World\");\n", | ||
" Book book2 = new Book(\"Things Fall Apart\");\n", | ||
" \n", | ||
" System.out.println(book1.toString() + \", ID: \" + book1.getId());\n", | ||
" System.out.println(book2.toString() + \", ID: \" + book2.getId());\n", | ||
" System.out.println(\"Total number of books: \" + Book.getBookCount());\n", | ||
" }\n", | ||
"}\n", | ||
"Book.main(null);" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"public class Fiction extends Book\n", | ||
"{\n", | ||
" private String title; \n", | ||
" private String author; \n", | ||
" private String shelfLife; \n", | ||
" \n", | ||
" \n", | ||
"\n", | ||
"\n", | ||
"}" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Java", | ||
"language": "java", | ||
"name": "java" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "java", | ||
"file_extension": ".jshell", | ||
"mimetype": "text/x-java-source", | ||
"name": "java", | ||
"pygments_lexer": "java", | ||
"version": "11.0.16+8-post-Ubuntu-0ubuntu120.04" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
Empty file.
Oops, something went wrong.