INFO1113 - Quiz1 Notes


Quiz 有毒 建议快跑
能来得及就见鬼了…
(今日份暴躁Tianna)

Practice Quiz

Compile & Run

√ javac test1.java test2.java; java test1.java

√ javac *.java; java test1

× javac test1.java test2.java; java test1.class

Overload - method

  • Invalid: different return type:
int Tianna(int a, String b)
double Tianna(int a, String b)
  • Valid:
  1. Different number of parameters
int Tianna(int a, int b)
int Tianna(int a, int b, int c)
  1. Different type of parameters
int Tianna(int a, int b)
int Tianna(int a, String b)
  1. Different sequence of type of parameters
int Tianna(int a, String b)
int Tianna(String a, int b)

Hashmap

  • Traverse the map:
for(HashMap.Entry<Integer,String> element : map.entrySet()){
      System.out.println(element.getKey() + " --> " + element.getValue());
    }

Notes

Superclass & Subclass

  • Subclass cannot be constructed using a superclass constructor
    √ Superclass a = new Subclass();
    × Subclass a = new Superclass();

I/O

import java.io.File;
import java.util.Scanner;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
GeoPandas是一个开源的Python库,旨在简化地理空间数据的处理和分析。它结合了Pandas和Shapely的能力,为Python用户提供了一个强大而灵活的工具来处理地理空间数据。以下是关于GeoPandas的详细介绍: 一、GeoPandas的基本概念 1. 定义 GeoPandas是建立在Pandas和Shapely之上的一个Python库,用于处理和分析地理空间数据。 它扩展了Pandas的DataFrame和Series数据结构,允许在其中存储和操作地理空间几何图形。 2. 核心数据结构 GeoDataFrame:GeoPandas的核心数据结构,是Pandas DataFrame的扩展。它包含一个或多个列,其中至少一列是几何列(geometry column),用于存储地理空间几何图形(如点、线、多边形等)。 GeoSeries:GeoPandas中的另一个重要数据结构,类似于Pandas的Series,但用于存储几何图形序列。 二、GeoPandas的功能特性 1. 读取和写入多种地理空间数据格式 GeoPandas支持读取和写入多种常见的地理空间数据格式,包括Shapefile、GeoJSON、PostGIS、KML等。这使得用户可以轻松地从各种数据源中加载地理空间数据,并将处理后的数据保存为所需的格式。 2. 地理空间几何图形的创建、编辑和分析 GeoPandas允许用户创建、编辑和分析地理空间几何图形,包括点、线、多边形等。它提供了丰富的空间操作函数,如缓冲区分析、交集、并集、差集等,使得用户可以方便地进行地理空间数据分析。 3. 数据可视化 GeoPandas内置了数据可视化功能,可以绘制地理空间数据的地图。用户可以使用matplotlib等库来进一步定制地图的样式和布局。 4. 空间连接和空间索引 GeoPandas支持空间连接操作,可以将两个GeoDataFrame按照空间关系(如相交、包含等)进行连接。此外,它还支持空间索引,可以提高地理空间数据查询的效率。
很好,这是一个非常好的练习。在这里,我将提供一些不同风格的教育app的示例,并展示如何使用CSS、JS、JQuery和功能来实现它们。 1. 教育游戏应用 这个应用程序主要旨在通过游戏方式教授概念。它将包含以下内容: - 题目列表 - 时间限制 - 得分板 - 游戏规则 HTML结构: ``` <div id="game"> <h1>教育游戏</h1> <div id="question-list"> <div class="question">问题1</div> <div class="question">问题2</div> <div class="question">问题3</div> </div> <div id="timer">时间: <span id="time-remaining"></span></div> <div id="scoreboard">得分: <span id="score"></span></div> <div id="rules">游戏规则</div> <button id="start">开始游戏</button> </div> ``` CSS样式: ``` #game { width: 400px; margin: 0 auto; text-align: center; } #question-list { margin-bottom: 20px; } .question { display: inline-block; margin: 0 10px; padding: 10px; background-color: #e0e0e0; cursor: pointer; } .question:hover { background-color: #ccc; } #timer, #scoreboard { margin-bottom: 10px; } #rules { margin-bottom: 20px; text-decoration: underline; cursor: pointer; } #start { padding: 10px; background-color: #4caf50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } #start:hover { background-color: #3e8e41; } ``` JS代码: ``` var questions = [ "问题1", "问题2", "问题3" ]; var score = 0; var timeRemaining = 60; function displayQuestions() { var questionList = document.getElementById("question-list"); for (var i = 0; i < questions.length; i++) { var questionElement = document.createElement("div"); questionElement.className = "question"; questionElement.innerHTML = questions[i]; questionList.appendChild(questionElement); } } function startGame() { var startButton = document.getElementById("start"); startButton.disabled = true; var timerElement = document.getElementById("time-remaining"); timerElement.innerHTML = timeRemaining; var timerInterval = setInterval(function() { timeRemaining--; timerElement.innerHTML = timeRemaining; if (timeRemaining <= 0) { clearInterval(timerInterval); endGame(); } }, 1000); var questionList = document.getElementById("question-list"); questionList.addEventListener("click", function(event) { var target = event.target; if (target.classList.contains("question")) { score++; target.classList.add("answered"); document.getElementById("score").innerHTML = score; } }); } function endGame() { var questionList = document.getElementById("question-list"); questionList.removeEventListener("click"); var startButton = document.getElementById("start"); startButton.disabled = false; score = 0; timeRemaining = 60; document.getElementById("score").innerHTML = score; var answeredQuestions = document.querySelectorAll(".answered"); for (var i = 0; i < answeredQuestions.length; i++) { answeredQuestions[i].classList.remove("answered"); } } displayQuestions(); document.getElementById("start").addEventListener("click", startGame); document.getElementById("rules").addEventListener("click", function() { alert("这是游戏规则"); }); ``` 2. 学习笔记应用 这个应用程序旨在允许学生在线创建笔记并将它们保存到他们的帐户中。 它将包含以下内容: - 登录表单 - 注册表单 - 笔记列表 - 笔记编辑器 HTML结构: ``` <div id="notes-app"> <div id="login-form"> <h2>登录</h2> <form> <div> <label for="username">用户名:</label> <input type="text" id="username" name="username"> </div> <div> <label for="password">密码:</label> <input type="password" id="password" name="password"> </div> <button type="submit">登录</button> </form> </div> <div id="register-form"> <h2>注册</h2> <form> <div> <label for="new-username">用户名:</label> <input type="text" id="new-username" name="new-username"> </div> <div> <label for="new-password">密码:</label> <input type="password" id="new-password" name="new-password"> </div> <button type="submit">注册</button> </form> </div> <div id="notes-list"> <h2>我的笔记</h2> <ul id="notes"> <li><a href="#">笔记1</a></li> <li><a href="#">笔记2</a></li> <li><a href="#">笔记3</a></li> </ul> <button id="new-note">新建笔记</button> </div> <div id="note-editor"> <h2>编辑笔记</h2> <form> <div> <label for="note-title">标题:</label> <input type="text" id="note-title" name="note-title"> </div> <div> <label for="note-body">内容:</label> <textarea id="note-body" name="note-body"></textarea> </div> <button type="submit">保存笔记</button> </form> </div> </div> ``` CSS样式: ``` #notes-app { width: 600px; margin: 0 auto; text-align: center; } form { display: inline-block; text-align: left; margin-right: 10px; } label { display: block; margin-bottom: 5px; } input[type="text"], input[type="password"], textarea { width: 100%; padding: 5px; margin-bottom: 10px; border-radius: 5px; border: 1px solid #ccc; } button[type="submit"], #new-note { padding: 10px; background-color: #4caf50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } button[type="submit"]:hover, #new-note:hover { background-color: #3e8e41; } #notes { list-style: none; margin: 0; padding: 0; } #notes li { margin-bottom: 10px; } ``` JS代码: ``` var notes = [ {title: "笔记1", body: "这是笔记1的内容。"}, {title: "笔记2", body: "这是笔记2的内容。"}, {title: "笔记3", body: "这是笔记3的内容。"} ]; var currentUser = null; function displayNotes() { var notesList = document.getElementById("notes"); notesList.innerHTML = ""; for (var i = 0; i < notes.length; i++) { var noteElement = document.createElement("li"); var noteLink = document.createElement("a"); noteLink.href = "#"; noteLink.innerHTML = notes[i].title; noteLink.addEventListener("click", function(event) { event.preventDefault(); var noteIndex = Array.prototype.indexOf.call(notesList.children, event.target.parentNode); displayNoteEditor(noteIndex); }); noteElement.appendChild(noteLink); notesList.appendChild(noteElement); } } function displayLoginForm() { document.getElementById("login-form").style.display = "block"; document.getElementById("register-form").style.display = "none"; document.getElementById("notes-list").style.display = "none"; document.getElementById("note-editor").style.display = "none"; } function displayRegisterForm() { document.getElementById("login-form").style.display = "none"; document.getElementById("register-form").style.display = "block"; document.getElementById("notes-list").style.display = "none"; document.getElementById("note-editor").style.display = "none"; } function displayNotesList() { document.getElementById("login-form").style.display = "none"; document.getElementById("register-form").style.display = "none"; document.getElementById("notes-list").style.display = "block"; document.getElementById("note-editor").style.display = "none"; displayNotes(); } function displayNoteEditor(noteIndex) { document.getElementById("login-form").style.display = "none"; document.getElementById("register-form").style.display = "none"; document.getElementById("notes-list").style.display = "none"; document.getElementById("note-editor").style.display = "block"; if (noteIndex === undefined) { document.getElementById("note-title").value = ""; document.getElementById("note-body").value = ""; } else { document.getElementById("note-title").value = notes[noteIndex].title; document.getElementById("note-body").value = notes[noteIndex].body; } } function login(event) { event.preventDefault(); var username = document.getElementById("username").value; var password = document.getElementById("password").value; // TODO: 登录逻辑 currentUser = username; displayNotesList(); } function register(event) { event.preventDefault(); var username = document.getElementById("new-username").value; var password = document.getElementById("new-password").value; // TODO: 注册逻辑 currentUser = username; displayNotesList(); } function saveNote(event) { event.preventDefault(); var noteTitle = document.getElementById("note-title").value; var noteBody = document.getElementById("note-body").value; if (noteTitle === "" || noteBody === "") { alert("标题和内容都不能为空!"); return; } var noteIndex = notes.findIndex(function(note) { return note.title === noteTitle; }); if (noteIndex === -1) { notes.push({title: noteTitle, body: noteBody}); } else { notes[noteIndex].body = noteBody; } displayNotes(); displayNotesList(); } displayLoginForm(); document.getElementById("login-form").addEventListener("submit", login); document.getElementById("register-form").addEventListener("submit", register); document.getElementById("new-note").addEventListener("click", function() { displayNoteEditor(); }); document.getElementById("note-editor").addEventListener("submit", saveNote); ``` 3. 在线课程应用 这个应用程序旨在允许学生在线学习课程。 它将包含以下内容: - 课程列表 - 课程详情 - 课程评论 HTML结构: ``` <div id="courses-app"> <div id="course-list"> <h2>可用课程</h2> <ul> <li><a href="#" data-id="1">课程1</a></li> <li><a href="#" data-id="2">课程2</a></li> <li><a href="#" data-id="3">课程3</a></li> </ul> </div> <div id="course-details"> <h2 id="course-title">课程1</h2> <p id="course-description">这是课程1的描述。</p> <ul id="course-comments"> <li>评论1</li> <li>评论2</li> <li>评论3</li> </ul> <form id="comment-form"> <div> <label for="comment">发表评论:</label> <input type="text" id="comment" name="comment"> </div> <button type="submit">提交评论</button> </form> </div> </div> ``` CSS样式: ``` #courses-app { width: 600px; margin: 0 auto; text-align: center; } #course-list, #course-details { display: inline-block; vertical-align: top; text-align: left; margin-right: 20px; } #course-list li { margin-bottom: 10px; } #course-details h2 { margin-bottom: 10px; } #course-details p { margin-bottom: 20px; } #course-details ul { list-style: none; padding: 0; margin: 0; margin-bottom: 20px; } #course-details ul li { margin-bottom: 10px; } #comment-form label { display: block; margin-bottom: 5px; } #comment-form input[type="text"] { width: 100%; padding: 5px; margin-bottom: 10px; border-radius: 5px; border: 1px solid #ccc; } #comment-form button[type="submit"] { padding: 10px; background-color: #4caf50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } #comment-form button[type="submit"]:hover { background-color: #3e8e41; } ``` JS代码: ``` var courses = [ {id: 1, title: "课程1", description: "这是课程1的描述。", comments: ["评论1", "评论2", "评论3"]}, {id: 2, title: "课程2", description: "这是课程2的描述。", comments: ["评论4", "评论5", "评论6"]}, {id: 3, title: "课程3", description: "这是课程3的描述。", comments: ["评论7", "评论8", "评论9"]} ]; function displayCourseList() { var courseList = document.getElementById("course-list").getElementsByTagName("ul")[0]; courseList.innerHTML = ""; for (var i = 0; i < courses.length; i++) { var courseElement = document.createElement("li"); var courseLink = document.createElement("a"); courseLink.href = "#"; courseLink.dataset.id = courses[i].id; courseLink.innerHTML = courses[i].title; courseLink.addEventListener("click", function(event) { event.preventDefault(); var courseId = event.target.dataset.id; displayCourseDetails(courseId); }); courseElement.appendChild(courseLink); courseList.appendChild(courseElement); } } function displayCourseDetails(courseId) { var course = courses.find(function(course) { return course.id == courseId; }); document.getElementById("course-title").innerHTML = course.title; document.getElementById("course-description").innerHTML = course.description; var commentsList = document.getElementById("course-comments"); commentsList.innerHTML = ""; for (var i = 0; i < course.comments.length; i++) { var commentElement = document.createElement("li"); commentElement.innerHTML = course.comments[i]; commentsList.appendChild(commentElement); } } function addComment(event) { event.preventDefault(); var comment = document.getElementById("comment").value; if (comment === "") { alert("评论不能为空!"); return; } var courseTitle = document.getElementById("course-title").innerHTML; var course = courses.find(function(course) { return course.title === courseTitle; }); course.comments.push(comment); displayCourseDetails(course.id); document.getElementById("comment-form").reset(); } displayCourseList(); document.getElementById("comment-form").addEventListener("submit", addComment); ``` 4. 在线测试应用 这个应用程序旨在允许学生在线参加测试。 它将包含以下内容: - 题目列表 - 选项列表 - 时间限制 - 得分板 HTML结构: ``` <div id="quiz-app"> <h2>在线测试</h2> <div id="question-list"> <div class="question"> <h3>问题1</h3> <ul> <li><input type="radio" name="q1" value="a">选项A</li> <li><input type="radio" name="q1" value="b">选项B</li> <li><input type="radio" name="q1" value="c">选项C</li> </ul> </div> <div class="question"> <h3>问题2</h3> <ul> <li><input type="radio" name="q2" value="a">选项A</li> <li><input type="radio" name="q2" value="b">选项B</li> <li><input type="radio" name="q2" value="c">选项C</li> </ul> </div> <div class="question"> <h3>问题3</h3> <ul> <li><input type="radio" name="q3" value="a">选项A</li> <li><input type="radio" name="q3" value="b">选项B</li> <li><input type="radio"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值