Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions student_no.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Please enter your 9-digit student number below.
100243353
10 changes: 5 additions & 5 deletions task1/sources/main.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// Create a struct called Wallet with a single field called balance of type u64.
module 0x42::Task1 {

// TODO
// Define a struct called Wallet with a single field called balance of type u64.
struct Wallet has drop {
// ...
balance: u64
}

// TODO
// Define a function called myWallet that returns a Wallet with a balance of 1000.
fun myWallet(): Wallet {
// ...
Wallet {
balance: 1000
}
}

#[test]
fun test_wallet() {
let wallet = myWallet();
assert!(wallet.balance == 1000, 0);
}
}
}
36 changes: 19 additions & 17 deletions task2/sources/main.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
module 0x42::Task2{
use std::signer;

// TODO
// Define a struct Foo with two fields: u: u64, b: bool with ability to drop
struct Foo {
// ...
struct Foo has drop {
u: u64,
b: bool
}

// TODO
// Define a function gen_Fool that takes two arguments: u: u64, b: bool and returns a Foo
fun gen_Fool(u:u64, b:bool): Foo {
// ...
return Foo {
u,
b
}
}

#[test]
Expand All @@ -30,16 +32,18 @@ module 0x42::Task2{
assert!(f.b == true,1);
}

// TODO
// Define a struct Soo with two fields: x: u64, y: u64 with ability to copy
struct Soo {
// ...
struct Soo has copy {
x: u64,
y: u64
}

// TODO
// Define a function gen_Soo that takes two arguments: x: u64, y: u64 and returns a Soo
fun gen_Soo(x:u64, y:u64): Soo {
// ...
return Soo {
x,
y
}
}

#[test]
Expand All @@ -54,23 +58,21 @@ module 0x42::Task2{
let Soo { x: _, y: _ } = c2;
}

// TODO
// Define a struct Koo with a field: s: Moo with ability
struct Koo {
s: Moo
}

// TODO
// Define a struct Moo with a field: x: u64 with ability
struct Moo {
struct Moo has store {
x: u64
}


// TODO
// Define a function gen_Moo that takes an argument: x: u64 and returns a Moo
fun gen_Moo(x:u64): Moo {
// ...
return Moo {
x
}
}

#[test]
Expand All @@ -80,4 +82,4 @@ module 0x42::Task2{
assert!(k.s.x == 42,0);
let Koo { s: Moo { x: _ } } = k;
}
}
}
15 changes: 6 additions & 9 deletions task3/sources/m1.move
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// Tasl3 - module
// Tasl3 - module

// Observe the function permissions called in M1, M2, and M3.
// modify the visibility of the functions in M1, and set the M1 module visibility.
module 0x42::M1{

// TODO
// Define a module friend M2
friend ;

// TODO
friend 0x42::M2;

// Define a function num that returns 66 with choose public or friend visibility
fun num():u64 {
public fun num():u64 {
66
}

// TODO
// Define a function num2 that returns 88 with choose public or friend visibility
fun num2():u64 {
public(friend) fun num2():u64 {
88
}
}
}
14 changes: 5 additions & 9 deletions task4/sources/main.move
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ module 0x42::Task4 {

use std::signer;

const NAME:vector<u8> = b"myObject";
const NAME:vector<u8> = b"myObject";

// TODO
// 1. create a deleteable object
public fun createDeleteableObject(caller: &signer):ConstructorRef {
// ...
object::create_object(signer::address_of(caller))
}

// TODO
// 2. create a named object
public fun createNamedObject(caller: &signer):ConstructorRef {
// ...
object::create_named_object(caller, NAME)
}

// TODO
// 3. create a sticky object
public fun createStickyObject(caller: &signer):ConstructorRef {
// ...
object::create_sticky_object(signer::address_of(caller))
}

#[test(caller = @0x88)]
Expand All @@ -49,4 +45,4 @@ module 0x42::Task4 {
assert!( object::address_from_constructor_ref(&obj2) == @0xfab16b00983f01e5c2b7682472a4f4c3e5929fbba987958570b6290c02817df2, 1);

}
}
}