Psuedocode, html, css and javascript and normalisation Flashcards
Describe a class diagram for a class called House with attributes for square footage and number of rooms.
Write the pseudocode for a fully encapsulated House class. You do not have to write code for the get and set methods.
class House
private squareFootage
private rooms
public procedure new (givenSquareFootage, givenRooms)
squareFootage = givenSquareFootage;
rooms = givenRooms;
endProcedure
endClass
Write pseudocode to create a House object.
myHouse = new House (5000, 10)
Psuedocode example for superclass
Psuedocode example for subclass
What must the subclass constructor always contain
A ‘super’ call and be the first statement in the subclass constructor
Example of a setter method
public procedure setName(newName)
name = newName
endProcedure
Example of a getter method
public function getName()
return name
endFunction
Are attributes + or -
- -to indicate private access modifier
Are methods + or -
+ to indicate public access modifier
How to read one line from a file
myFile = openRead(“test.txt”)
line = myFile.readLine()
myFile.close()
What is the issue with reading lines
Cannot go to a specific line to read it the code will read the first line
Printing all lines from a file
myFile = openRead(“sample.txt”)
while NOT myFile.endOfFile()
print(myFile.readLine())
endwhile
myFile.close()
Writing one line to a file
myFile = openWrite(“sample.txt”)
myFile.writeLine(“Hello World”)
myFile.close()
First normal form
each record (row) is unique i.e. it has a primary key
Each data item cannot be broken down any further (is atomic) e.g. addresses should be broken up
Each field (column) has an unique name
No fields (columns) that represent a group of data
Second normal form
Non-key fields must depend on every part of the primary key. If the primary key is not composite, this condition will be met
What is a composite primary key
When 2 fields together are used as the primary key
Third normal form
Non-key fields depend only on the primary key, could not have branch name which depends on branch ID if branch ID was not the primary key
How to use image tag html
How to use link tag html
<a> PMT </a>
How to declare a variable in javascript
var name=”Sophie”
How to declare an array in javascript
var cars=[“Saab”,”Volvo”,”BMW”];
How to write a for loop in javascript
for (var i = 0; i < 5 ; i++) {
text += “Hello” + “<br></br>”;
}
How to write a while loop javascript
while (i < 10) {
text += “<br></br>The number is “ + i;
i++;
Branching in javascript
if (document.getElementById(‘express’).checked) {
expressCost = 5
}
How to output by changing the contents of an HTML element eg
document.getElementById(‘name’).innerHTML = “Bob”;
How to output using an alert box
alert(“Hello world”);
How to output by writing directly to the page
document.write(“Hey Bob”)
Example of defining a class in html
.example { // defining
background-color: green; a class
border: 1px solid black;
}
Example of using a class in html
<div class = ‘example’>
<p> This paragraph will have a green background and a black
border </p>
</div>
How to change background colour
background-colour
How to change border colour
border-colour
How to change border style
border-style
how to change border width
border-width
How to change colour (with named and hex colours)
color
How to change the family of the font
font-family
How to change the size of the font
font-size
How to change the style of the font
font-style
How to change the height
height
How to change the width
width
How to use classes
To identify multiple elements
How to use identifiers
To identify one element
Example of using an identifier
How to get value using get element
document.getElementById(“num1”).value;
Whenever an external style sheet is used, where is the link added to
The header
What is the link when you use an external style sheet
<link></link>
Styling body
body
{
margin: 0px;
}
document.getElementById(‘name’).innerHTML = “Bob”; or
chosenElement=document.getElementById(“example”);
chosenElement.innerHTML = “Hello World”;