Notes, summaries, assignments, exams, and problems for Computer science

Multi-Threaded TCP Game Server Implementation

Computer science1.34 KB

Clientes ligam-se a servidor por TCP para jogarem. Pode ter entre 20 a 30 jogadores, de preferência 30, mas se jogador esperar mais de 1 minuto a partida começa com pelo menos 20. O jogador envia o nome ao servidor e fica à espera que o jogo comece e nessa altura é informado dos nomes dos outros.
1. Apresentar uma classe que implementa a interface em que os métodos têm que ser invocados em multi-thread.
Interface Jogo { List inscrever(String nome);}
public class Cliente {
public Cliente(Socket s) throws Exception {
PrintWriter pw = new PrintWriter(s.getOutputStream(), true);
BufferedReader bf = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedReader terminal = new BufferedReader(new InputStreamReader(System.in))
...
Continue reading "Multi-Threaded TCP Game Server Implementation" »

Reverse Engineering Fundamentals: Process, Steps, and CAD Model Generation

Computer science2.76 KB

Forward Engineering Defined

Forward engineering is the traditional process of moving from high-level abstractions and logical designs to the physical implementation of a system.

Understanding Reverse Engineering

Reverse engineering (RE) is the process of duplicating an existing part, sub-assembly, or product without original drawings, documentation, or a computer model.

It is also defined as the process of obtaining a geometric Computer-Aided Design (CAD) model from 3-D points acquired by scanning or digitizing existing parts.

Alternative Name for Reverse Engineering

The process is often referred to as the Physical-to-Digital process.

Key Purposes of Reverse Engineering (RE)

Reverse engineering serves several critical functions, including:

  • The user
...
Continue reading "Reverse Engineering Fundamentals: Process, Steps, and CAD Model Generation" »

Understanding Operating Systems: Traps, Interrupts, System Calls, and Threads

Computer science3.94 KB

What is the Key Difference Between a Trap and an Interrupt?

A trap is caused by the program and is synchronous with it. If the program is run again and again, the trap will always occur at exactly the same position in the instruction stream. An interrupt is caused by an external event and its timing is not reproducible.

Why is the Process Table Needed in a Timesharing System?

The process table is needed to store the state of a process that is currently suspended, either ready or blocked. It is not needed in a single-process system because the single process is never suspended.

Is the Process Table Needed in Personal Computer Systems With Only One Process?

No, it is not needed in a single-process system because the single process is never suspended....

Continue reading "Understanding Operating Systems: Traps, Interrupts, System Calls, and Threads" »

Software Design Patterns: Enhancing Flexibility and Structure

Computer science3.73 KB

Design patterns offer proven solutions to recurring software design challenges, promoting code reusability, maintainability, and efficiency. They can be categorized into three main types:

Behavioral Design Patterns

These patterns focus on communication and interaction between objects, enhancing flexibility. Examples include:

  • Observer Pattern: Enables one-to-many dependencies, where changes in one object automatically notify dependent objects.
  • Iterator Pattern: Provides sequential access to elements within a collection without exposing its underlying structure.

Creational Design Patterns

These patterns address object creation mechanisms, ensuring suitable instantiation processes. Examples include:

  • Singleton Pattern: Restricts object creation to a single
...
Continue reading "Software Design Patterns: Enhancing Flexibility and Structure" »

Excel 2016 Practice Questions and Answers

Computer science3.22 KB

Excel Practice Questions and Answers

  1. The ________ displays the current cell mode, the page number, and the zoom buttons.

    Answer: Status bar

  2. A text value in Excel is also referred to as a ________.

    Answer: Label

  3. When you type text in a cell, it is ________.

    Answer: Left-aligned

  4. Which of the following is NOT a way to create a formula?

    Answer: By using a Function button on the status bar

  5. ________ is a procedure that determines which digit to the right of a number will be the last to be displayed.

    Answer: Rounding

  6. Which of the following is NOT part of the Accounting Number Format?

    Answer: Three decimal places

  7. Tiny charts embedded in a cell that display a visual trend summary alongside your data are called ________.

    Answer: Sparklines

  8. What are the two contextual

...

Continue reading "Excel 2016 Practice Questions and Answers" »

Alpha Vantage API Integration for Stock Market Data

Computer science3.22 KB

Stock Market Data Integration

Listar

Stock Data Table Headers

OPENHIGHLOWCLOSEVOLUME

Alpha Vantage API Implementation

The following script utilizes jQuery AJAX to fetch real-time stock data for MSFT from the Alpha Vantage API.


function main() {
    $("#list").click(function() {
        $.ajax({
            type: "GET",
            url: "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=1min&apikey=demo",
            success: function (azul) {
                var roxo = azul["Time Series (1min)"];
                for (var verde in roxo) {
                    var vermelho = roxo[verde];
                    var str = "<tr><td>" + vermelho["1. open"] + "</td>"
...
Continue reading "Alpha Vantage API Integration for Stock Market Data" »

Web Development Fundamentals

Computer science117.12 KB

Pseudo Classes

Pseudo classes are selectors that can be used to style elements based on their state or position in the document. For example, the :hover pseudo class can be used to style an element when the user hovers over it with the mouse.

:nth-of-type(an+b || even || a || an)

The :nth-of-type pseudo class is used to select elements based on their position in a group of siblings. It takes an argument that specifies which elements to select. The argument can be one of the following:

  • an+b: Selects every nth element, starting with the bth element. For example, 2n would select every other element, and 2n+1 would select every odd element.
  • even: Selects every even-numbered element.
  • odd: Selects every odd-numbered element.
  • a: Selects every element.

For...

Continue reading "Web Development Fundamentals" »

Essential Tech Terms: A Comprehensive Glossary

Computer science4.83 KB

RAM (Random Access Memory)

Random Access Memory is one of two basic types of memory. Portions of programs are stored in RAM when the program is launched so that the program will run faster. Though a PC has a fixed amount of RAM, only portions of it will be accessed by the computer at any given time. Also called memory.

Scrolling

Scrolling allows lines displayed on the screen to be moved up or down by one line as a new line is added and an existing one is removed.

Shooter

A shooter is a game whose main focus is combat involving guns or other projectile weapons such as missiles.

Shopping Cart

A shopping cart is software that keeps track of what you buy on a site.

Software Engineer

A software engineer is a person that writes computer programs.

Speech Recognition

Speech

...
Continue reading "Essential Tech Terms: A Comprehensive Glossary" »

Como Criar uma Calculadora em JavaScript com Atalhos

Computer science3.88 KB

Implementação de Calculadora em JavaScript

Abaixo está o código fonte completo e corrigido para o funcionamento de uma calculadora web utilizando JavaScript, incluindo suporte para eventos de teclado e operações matemáticas básicas.

Listener para Teclas do Teclado

Este trecho monitora as teclas pressionadas pelo usuário, mapeando números e operadores para as funções correspondentes da calculadora.

document.addEventListener('DOMContentLoaded', function(){
	document.addEventListener('keypress', function(e){
		if (e.which == 48){ inserirNumConsole('0'); }
		else if (e.which == 49){ inserirNumConsole('1'); }
		else if (e.which == 50){ inserirNumConsole('2'); }
		else if (e.which == 51){ inserirNumConsole('3'); }
		else if (e.which == 52)
...
Continue reading "Como Criar uma Calculadora em JavaScript com Atalhos" »

Mastering Vector Drawing Tools and Basic Shapes

Computer science3.48 KB

Freeform Vector Drawing Tools

In the Toolbar, within the Vector group, you will find the tools that allow you to draw freely: the Line and Pen tools.

To use them, simply select the desired tool from the Toolbar and move the mouse to the work area. Click the mouse where you wish to start and keep the button pressed until you reach the end point.

The Line Tool

The line is the simplest vector element, as it is composed of only two points and the line that connects them.

With this tool, you can form different lines to create the desired figure. Example of Line Tool usageTo deselect a line, click in the negative area of the document. To select it again, grab the Pointer Tool from the Select group in the Toolbar. Example of selecting and deselecting a line

Using the Properties Inspector

Always remember to observe the Properties

...
Continue reading "Mastering Vector Drawing Tools and Basic Shapes" »