diff --git a/student_no.txt b/student_no.txt index 2a6816f..b99295e 100644 --- a/student_no.txt +++ b/student_no.txt @@ -1 +1,2 @@ # Please enter your 9-digit student number below. +100243246 diff --git a/task1/sources/main.move b/task1/sources/main.move index 2507060..2b78080 100644 --- a/task1/sources/main.move +++ b/task1/sources/main.move @@ -5,13 +5,13 @@ 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] diff --git a/task2/sources/main.move b/task2/sources/main.move index d6746d8..3aa1c6b 100644 --- a/task2/sources/main.move +++ b/task2/sources/main.move @@ -1,17 +1,17 @@ // Task2 - drop, copy, store 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 { - // ... + Foo{u, b} } #[test] @@ -32,14 +32,15 @@ module 0x42::Task2{ // 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 { - // ... + Soo{x,y} } #[test] @@ -56,13 +57,13 @@ module 0x42::Task2{ // TODO // Define a struct Koo with a field: s: Moo with ability - struct Koo { + struct Koo has drop{ s: Moo } // TODO // Define a struct Moo with a field: x: u64 with ability - struct Moo { + struct Moo has store, drop{ x: u64 } @@ -70,7 +71,7 @@ module 0x42::Task2{ // TODO // Define a function gen_Moo that takes an argument: x: u64 and returns a Moo fun gen_Moo(x:u64): Moo { - // ... + Moo{x} } #[test] diff --git a/task3/sources/m1.move b/task3/sources/m1.move index e3542c4..02c25c5 100644 --- a/task3/sources/m1.move +++ b/task3/sources/m1.move @@ -6,17 +6,17 @@ module 0x42::M1{ // TODO // Define a module friend M2 - friend ; + friend 0x42::M2; // TODO // 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 } } \ No newline at end of file diff --git a/task3/sources/m3.move b/task3/sources/m3.move index 1b25c74..1748ac0 100644 --- a/task3/sources/m3.move +++ b/task3/sources/m3.move @@ -4,6 +4,6 @@ module 0x42::M3{ use 0x42::M1::num; let n = num(); - assert(n == 66,0); + assert!(n == 66,0); } } \ No newline at end of file diff --git a/task4/sources/main.move b/task4/sources/main.move index daa4423..cc194ea 100644 --- a/task4/sources/main.move +++ b/task4/sources/main.move @@ -12,19 +12,19 @@ module 0x42::Task4 { // 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)]