Notes, summaries, assignments, exams, and exercises for Computer science for University

Java Servlet Bookstore: Cart and Checkout Logic Explained

Computer science4.36 KB

LibreriaServlet

package servlet;

public class LibreriaServlet extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

HttpSession session = request.getSession(false);

Almacen almacen = new Almacen();

List<Libro> librosDisponibles = new ArrayList<Libro>();

try {

librosDisponibles = almacen.consultaLibrosDisponibles();

} catch (Exception e) {

PrintWriter out = response.getWriter();

out.print("ERROR: " + e.getMessage());

out.close();

}

if (session != null) {

String accion = request.getParameter("Accion");

if (accion.equals("agregar"...

Continue reading "Java Servlet Bookstore: Cart and Checkout Logic Explained" »

OpenCV C++ Tutorial: Load and Process Images with IplImage

Computer science2.91 KB

OpenCV C Source Code for Image Processing

Below is a complete C program utilizing the OpenCV library to load, display, and process two images using IplImage.

Required Libraries

#include <stdio.h>
#include <stdlib.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>

Main Function and Validation

int main(int argc, char **argv) 
{
    if (argc != 3) // e.g., fruits, birds
    {
        printf("Error: Usage %s image_file_name\n", argv[0]);
        return EXIT_FAILURE;
    }
    // CV_LOAD_IMAGE_COLOR = 1 forces the resultant IplImage to be colour.
    // CV_LOAD_IMAGE_GRAYSCALE = 0 forces a greyscale IplImage.
    // CV_LOAD_IMAGE_UNCHANGED = -1

    // IMG1
    IplImage* Img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED);
...
Continue reading "OpenCV C++ Tutorial: Load and Process Images with IplImage" »

Galería de Imágenes Interactiva con jQuery: Cambio de Fotos y Miniaturas

Computer science3.16 KB

Galería de Imágenes que Cambian

HTML





Clase 2



















$("#thumb1").click(function(){
$("#foto1").attr("src","images/foto1.jpg");
$("#thumb1").attr("src","images/thumbs_bn/Foto1.jpg");
$("#thumb2").attr("src","images/thumbs/Foto2.png");
$("#thumb3").attr("src","images/thumbs/Foto3.jpg");
$("#thumb4").attr("src","images/thumbs/Foto4.png");
});
$("#thumb2").click(function(){
$("#foto1").attr("src","images/foto2.png");
$("#thumb2").attr("src","images/thumbs_bn/Foto2.png");
$("#thumb1").attr("src","images/thumbs/Foto1.jpg");
$("#thumb3").attr("src","images/thumbs/Foto3.jpg");
$("#thumb4").attr("src","images/thumbs/Foto4.png");
});
$("#thumb3").click(function(){
$("#foto1").attr("src","images/foto3.jpg");
$("#thumb3").attr("src","images/thumbs_bn/Foto3.
...
Continue reading "Galería de Imágenes Interactiva con jQuery: Cambio de Fotos y Miniaturas" »

Estructura de Árbol Binario en Java: Implementación con Nodos, Recorridos y Búsqueda

Computer science12.15 KB

Estructura base

++++++++++++++++++++++++++++++++++++

Árbol binario

Nombre del package: cl.duoc.ded.tree;

Clase Nodo

----------------------------

package cl.duoc.ded.tree;

public class Nodo {
    private int valor;
    private Nodo padre;
    private Nodo hojaIzquierda;
    private Nodo hojaDerecha;
    
    public Nodo (int valor) {
        this.valor = valor;
    }

    public int getValor() {
        return valor;
    }

    public void setValor(int valor) {
        this.valor = valor;
    }

    public Nodo getPadre() {
        return padre;
    }

    public void setPadre(Nodo padre) {
        this.padre = padre;
    }

    public Nodo getHojaIzquierda() {
        return hojaIzquierda;
    }

    public void setHojaIzquierda(Nodo hojaIzquierda)
...
Continue reading "Estructura de Árbol Binario en Java: Implementación con Nodos, Recorridos y Búsqueda" »

Aluno Java Class with JDBC CRUD Operations for Student Management

Computer science3.91 KB

Aluno Class in Java: Student Management with JDBC

The following Java class, Aluno, represents a student and provides methods to create, read, update and delete records in the aluno table using JDBC.

package classes;

import java.sql.*;
import classes.Conexao;

public class Aluno {

    private int idaluno = 0;
    private String nome = "";
    private String endereco = "";
    private String cidade = "";
    private String estado = "";
    private String pais = "";
    private String cep = "";

    public int getIdaluno() {
        return idaluno;
    }

    public void setIdaluno(int idaluno) {
        this.idaluno = idaluno;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.
...
Continue reading "Aluno Java Class with JDBC CRUD Operations for Student Management" »

Sequential Circuits: Latches, Flip-Flops, and Registers

Computer science2.57 KB

Sequential Circuits

A sequential circuit is a system where outputs at a specific instant are a function of the inputs at that instant and the current state of the circuit; essentially, they store information. A sequential system consists of two distinct blocks: a combinational system to process information and a memory system to store it. Generally, feedback circuits are present in these systems.

Memory Elements: Latches and Flip-Flops

Information is stored in binary format. The basic memory elements are latches and flip-flops, which store a single bit of information. These are elementary logical circuits that remain in one of two possible states (Q=0 or Q=1) and switch between them based on triggering inputs.

Classification of Sequential Circuits

By

...
Continue reading "Sequential Circuits: Latches, Flip-Flops, and Registers" »

Operating System Networking and Server Management

Computer science3.3 KB

Operating System Networking

Network software is installed on each computer to enable communication with others.

Services Performed

  • File support
  • Communications
  • Service P / support team

Server Operating System Management

Managing a server in an easy and safe manner is essential for anyone whose professional work involves managing a computer system.

Composition of the Operating System

  • Core: This module is the lowest level of an OS. It lies directly on the computer hardware.
  • Memory Manager: This module is responsible for absorbing certain portions of main memory for the various programs or program parts that need it.
  • System Input / Output: This component presents the user with the I/O data from the device as a separate issue.
  • Admin Archives: Responsible for
...
Continue reading "Operating System Networking and Server Management" »

Fundamentals of Programming Logic and Algorithms

Computer science118.85 KB

What is an Algorithm?

An algorithm is formally defined as a finite sequence of steps that lead to the execution of a specific task. Common examples include the basic operations of arithmetic—addition, multiplication, division, and subtraction—performed on real decimal numbers.

Core Characteristics of Algorithms

An algorithm must possess four essential characteristics:

  • Finite: It must eventually come to an end.
  • Definite: Each step must be precisely defined.
  • Inputs: It receives zero or more quantities from the outside.
  • Outputs: It produces at least one result.

Forms of Representation

Algorithms can be represented through various methods:

  • Narrative Description: Using natural language.
  • Flowchart: A conventional graphical representation.
  • Pseudocode: Also
...
Continue reading "Fundamentals of Programming Logic and Algorithms" »

Understanding Fuzzy Logic and Backpropagation in Neural Networks

Computer science2.43 KB

Fuzzy Logic

Fuzzy logic extends Boolean logic, allowing intermediate values between TRUE (1) and FALSE (0), such as MAYBE (0.5). A fuzzy logic value can be any value within the range of 0 to 1. This logic incorporates statistical concepts, especially in inference. Fuzzy logic implementations enable control devices to handle indeterminate states, allowing for the evaluation of non-quantifiable concepts. Practical examples include evaluating temperature (hot, warm, medium), happiness (bright, happy, apathetic, sad), and the veracity of an argument (absolutely right, right, counter-argumentative, inconsistent, false, totally wrong).

Fuzzy logic is a research area focused on uncertainty treatment and a family of mathematical models dedicated to...

Continue reading "Understanding Fuzzy Logic and Backpropagation in Neural Networks" »

Cisco IOS Configuration Commands and Security Settings

Computer science4.53 KB

Cisco Device Access and Security Passwords

  • Console Password: Provides limited access for devices via the console connection.
  • Enable Password: Restricts access to the privileged EXEC mode.
  • Enable Secret Password: An encrypted password restricting access to the privileged EXEC mode.
  • VTY Password: Limits access to devices using Telnet.

Basic Configuration Command Examples

Console Access Configuration

Switch(config)# line console 0
Switch(config-line)# password password
Switch(config-line)# login

Virtual Terminal (VTY) Access

Router(config)# line vty 0 4
Router(config-line)# password password
Router(config-line)# login

Banner Message of the Day

Switch(config)# banner motd # message #

Interface IP Address Assignment

Router(config)# interface FastEthernet 0/0
Router(

...
Continue reading "Cisco IOS Configuration Commands and Security Settings" »