Hi, my name is ...
I study ...
Choose one
Assignment 1
Assignment 2
35% of the course
Both assignments involve are quite large.
It is crucial that you start these early, at least a week before to comfortably finish the assignment on time.
UNSW students say walking across campus is slow and too energy-intensive (especially up those stairs 😮💨).
UNSW has decided that they want to create their own light rail, which takes students from upper campus to lower campus.
Design a solution for this - how will it work? What will need to be changed about the campus layout for it to work?
#include <stdio.h>
struct Car {
char brand[20];
int speed;
};
void drive(struct Car c) {
printf("%s is driving %d km/h\n", c.brand, c.speed);
}
int main() {
struct Car myCar = {"Toyota", 100};
drive(myCar); // function acts on struct
return 0;
}
class Car {
String brand;
int speed;
void drive() {
System.out.println(
brand + " is driving at " + speed + " km/h"
);
}
}
public class Main {
public static void main(String[] args) {
Car myCar = new Car();
myCar.brand = "Toyota";
myCar.speed = 100;
myCar.drive(); // method belongs to the object
}
}
Structure of a Java Class
What is abstraction?
How is abstraction used in Java or other object oriented languages?
What examples of abstraction have we seen in previous courses?
What examples of abstraction have we seen in previous courses?
#include “list.h”
int main(void) {
List l = newList();
l.insert(20);
l.insert(10);
l.pop();
}
Typedef list* List;
List newList();
// insert an element at the end of the list
void insert(List list, int element);
// get the last element of the list
int pop(List list);
typedef _list {
int element;
List next;
} list
List newList () {
List l = malloc(sizeof(list));
return l;
}
....
listClient.c
list.h
list.c
What examples of abstraction have we seen in previous courses?
/auth/register
/auth/login
/channels/create
/admin/auth/remove
/message/send
function authRegister (
email: String, name: String) {
return true;
}
....
function channelCreate
(uid: number) {
const c: Channel = {
owner: uid;
}
}
....
Routes (server.ts)
auth.ts
channel.ts
Frontend
OOP encapsulates data (attributes) and behaviour (methods) into classes, hiding the internal state.
All interaction with this data and behaviour is hidden from the outer world through access modifiers with access only permitted to certain functions/properties (e.g. getters/setters)