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

245 Midterm Challenge: Animals, Sunscreen Tips and Cat Records

Computer science1.86 KB

This Is Our CIS Midterm 245 Challenge!

These Are My Fave Animals:

  • Grizzly Bear
  • Bald Eagle
  • Moose
  • Beaver
  • Salmon
  • Wolf
Why? Tests Are Important

Visit UFV CIS Website

Why? Tests Are Not Important

Sunscreen Reminder

It's Very Important To Use Sunscreen In The Summer!

UFV Logo

UFV Is The Great Est School Ever. We Old Love Each Other & Did Color Green!

Cat 1: Type: Grade: Submit PC Midterms Are A Lot Of Fun

AnimalTypeDescription
Grizzly BearMammalLarge omnivore native to North America.

<?php // Database Insert $servername = "localhost"; $username = "root"; $password = ""; $dbname = "catserver"; $conn = new mysqli($servername, $username, $password, $dbname); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $cat_name = $_POST['cat_name']; $cat_type = $_POST['cat_type'];...

Continue reading "245 Midterm Challenge: Animals, Sunscreen Tips and Cat Records" »

C# Currency Persistence Class Implementation

Computer science3.25 KB

Namespace Pers
{
    public class Persistencia
    {
        

Method: Add Currency (AniadirDivisa)

Adds a currency and its value to Divisas.txt if it does not already exist.

public static void AniadirDivisa(String d, double valor)
{
    if (!ExisteDivisa(d))
    {
        StreamWriter sw = new StreamWriter(@"Divisas.txt", true);
        sw.WriteLine(d + "\t" + valor);
        sw.Close();
    }
}

Method: Get Currency Value (ValorDivisa)

Retrieves the value associated with a specific currency symbol.

public static double ValorDivisa(String d)
{
    String v = "";
    StreamReader sr = new StreamReader(@"Divisas.txt");
    String l = sr.ReadLine();
    while (l != null)
    {
        if (l.Contains(d))
        {
            // Extracts the value
...
Continue reading "C# Currency Persistence Class Implementation" »

x86 Assembly Program: Procedures, FPU Stack and Array Processing

Computer science18.51 KB

//მოდელისთვის განკუთვნილი სეგმენტი
//უბრალოდ საჭიროა ყველგან
.model flat, stdcall
//სტეკისთვის განკუთვნილი სეგმენტი
//უბრალოდ საჭიროა ყველგან
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
//მონაცემებისთვის განკუთვნილი სეგმენტი
.data
//პირველი პროცედურისთვის საჭირო მონაცემები
var_x QWORD 1.2 //შევარჩიეთ პირობითად, შესაძლოა მოცემული იყოს
...
Continue reading "x86 Assembly Program: Procedures, FPU Stack and Array Processing" »

Java Applet Animation: Moving a Red Ball Between Rectangles with Graphics

Computer science1.34 KB

Java Applet Animation: Moving a Red Ball Between Rectangles

import java.awt.*;

import java.applet.*;

public class universo05 extends Applet {

int x1, y1, ref1;

int x2, y2, ref2;

public void init() {

setSize(1500, 800);

x1 = 110;

y1 = 100;

ref1 = 1;

x2 = 100;

y2 = 150;

ref2 = 1;

}

public void paint(Graphics g) {

g.setColor(Color.cyan);

g.fillRect(100, 100, 400, 50);

g.fillRect(100, 450, 400, 50);

g.setColor(Color.blue);

g.drawLine(100, 500, 500, 100);

g.setColor(Color.red);

g.fillOval(x1, y1, 50, 50);

if (ref1 == 1) x1++;

if (ref1 == 2) {

x1--;

y1++;

}

if (ref1 == 3) x1++;

if (ref1 == 4) x1--;

if (ref1 == 5) {

x1++;

y1--;

}

if (ref1 == 6) x1--;

if (x1 == 450)

if (y1 == 100)

if (ref1 == 1)

ref1 = 2;

if (x1 == 100)

if (y1 == 450)

if (ref1 == 2)

ref1 = 3;

if (x1 == 450)

if (y1 == 450)

if...

Continue reading "Java Applet Animation: Moving a Red Ball Between Rectangles with Graphics" »

C++ Date Class: Calculate Differences and Add Days

Computer science4.92 KB

C++ Date Class with Operator Overloading

The following program defines a date class in C++ that calculates the difference between two dates, adds a number of days to a date, and handles leap years correctly.

Source Code

#include<iostream.h>
#include<conio.h>
#include<process.h>

class date
{
private:
    int flag, day, month, year;
public:
    date(int d, int m, int y)
    {
        day = d, month = m, year = y;
        if (year % 4 == 0)
            flag = 1;
        else
            flag = 0;
    }
    int operator-(date d2);
    date operator+(int n);
    int operator>(date d2);
    friend ostream& operator<<(ostream& out, date d1);
    int return_integer_date(date d1);
};

int a[13] = {0, 31, 28, 31, 30,
...
Continue reading "C++ Date Class: Calculate Differences and Add Days" »

Java Applet Bouncing Circle Animation Code Example

Computer science6.66 KB

import java.awt.*;

import java.applet.*;

public class Ocho extends Applet {

Variable Declaration

int x1, y1, ref1;

int x2, y2, ref2;

public void init() {

Variable Initialization

x1 = 100;

y1 = 100;

ref1 = 1;

x2 = 300;

y2 = 400;

ref2 = 1;

}

public void paint(Graphics g) {

Drawing

g.drawRect(100, 100, 300, 300);

g.fillOval(x1, y1, 50, 50);

Behaviors

if (ref1 == 1) x1++;

if (ref1 == 2) y1++;

if (ref1 == 3) x1--;

if (ref1 == 4) y1--;

Limits

if (x1 == 100)

if (y1 == 100) ref1 = 1;

if (x1 == 350)

if (y1 == 100) ref1 = 2;

if (x1 == 350)

if (y1 == 350) ref1 = 3;

if (x1 == 100)

if (y1 == 350) ref1 = 4;

repaint();

}

}



import java.awt.*;

import java.applet.*;

public class Ocho extends Applet {

Variable Declaration

int x1, y1, ref1;

int x2, y2, ref2;

public void init() {

Variable Initialization

x1

...
Continue reading "Java Applet Bouncing Circle Animation Code Example" »

Java DAO Pattern Implementation with Oracle Database

Computer science19.44 KB

Java Beans Implementation

public class AnimalBean implements Serializable {

private int nr_matricula;
private ClienteBean cliente;
private RacaBean raca;
private String nm_animal;
private String ds_cor;
private Date dt_nascimento;


public AnimalBean(){}

public AnimalBean(int nr_matricula, ClienteBean cliente, RacaBean raca,
String nm_animal, String ds_cor, Date dt_nascimento) {
super();
this.nr_matricula = nr_matricula;
this.cliente = cliente;
this.raca = raca;
this.nm_animal = nm_animal;
this.ds_cor = ds_cor;
this.dt_nascimento = dt_nascimento;
}

DEPOIS GERAR GET AND SET


public class ClienteBean implements Serializable {

private int codCliente;
private String nm_cliente;
private long nr_cpf;
private String ds_senha;
private String ds_email;
private int nr_fone;
private...

Continue reading "Java DAO Pattern Implementation with Oracle Database" »

Partition Table Reader and Hide/Reveal Tool in C for DOS and Win98

Computer science7.88 KB

Partition Table Reader and Hide/Reveal Tool

Release date: 1.1.2006

Author: Tapan Kumar Mishra
7th Semester, Electrical Engineering
IGIT Sarang, Orissa
Email: [email protected]

About the Program

This program is a part of my project to read the ext2 Linux file system under DOS or Windows 98. It reads the partition table of your hard disk, prints information about each partition, and can hide and reveal partitions by changing the system ID of those partitions.

Caution

Modification of the code may make your disk unusable. The author is not responsible for any damage or data loss.

Compatibility and Compilation

  • This program is tested under Windows 98.
  • Compile it with Turbo C 3.

For any comments, feedback, or queries, email [email protected].

Source

...
Continue reading "Partition Table Reader and Hide/Reveal Tool in C for DOS and Win98" »