From 614d96e6d406557a240c601ebb91e874b7d3c468 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:22:37 +0800 Subject: [PATCH 1/8] Update student_no.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 学号 --- student_no.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/student_no.txt b/student_no.txt index 2a6816f..46fd76d 100644 --- a/student_no.txt +++ b/student_no.txt @@ -1 +1,2 @@ # Please enter your 9-digit student number below. +100243361 From 897ccbe01c3f525efb30461d3ebac33368181926 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:23:45 +0800 Subject: [PATCH 2/8] Update main.move --- task1/sources/main.move | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/task1/sources/main.move b/task1/sources/main.move index 2507060..724144f 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] @@ -19,4 +19,4 @@ module 0x42::Task1 { let wallet = myWallet(); assert!(wallet.balance == 1000, 0); } -} \ No newline at end of file +} From d174369ada605ec90db205e750b7145b4d2aea70 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:24:54 +0800 Subject: [PATCH 3/8] Update main.move --- task2/sources/main.move | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/task2/sources/main.move b/task2/sources/main.move index d6746d8..cdadda0 100644 --- a/task2/sources/main.move +++ b/task2/sources/main.move @@ -4,14 +4,15 @@ module 0x42::Task2{ // 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 } #[test] @@ -32,14 +33,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 drop, 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 } #[test] @@ -56,13 +58,13 @@ module 0x42::Task2{ // TODO // Define a struct Koo with a field: s: Moo with ability - struct Koo { + struct Koo has key,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 +72,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// ... } #[test] @@ -80,4 +82,4 @@ module 0x42::Task2{ assert!(k.s.x == 42,0); let Koo { s: Moo { x: _ } } = k; } -} \ No newline at end of file +} From 10cf5c759c7c059ae3f72274be91825b80936fc5 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:25:49 +0800 Subject: [PATCH 4/8] Update m1.move --- task3/sources/m1.move | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/task3/sources/m1.move b/task3/sources/m1.move index e3542c4..e45d6ab 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 +} From 70dd92df4b8af32fd7f8dd0af351d2eb6256a4f4 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:26:22 +0800 Subject: [PATCH 5/8] Update main.move --- task4/sources/main.move | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/task4/sources/main.move b/task4/sources/main.move index daa4423..bbc861e 100644 --- a/task4/sources/main.move +++ b/task4/sources/main.move @@ -12,19 +12,24 @@ module 0x42::Task4 { // TODO // 1. create a deleteable object public fun createDeleteableObject(caller: &signer):ConstructorRef { - // ... + let caller_addr = signer::address_of(caller); + let obj = object::create_object(caller_addr); + obj } // TODO // 2. create a named object public fun createNamedObject(caller: &signer):ConstructorRef { - // ... + let obj = object::create_named_object(caller,NAME); + obj } // TODO // 3. create a sticky object public fun createStickyObject(caller: &signer):ConstructorRef { - // ... + let caller_addr = signer::address_of(caller); + let obj = object::create_sticky_object(caller_addr); + obj// ... } #[test(caller = @0x88)] @@ -49,4 +54,4 @@ module 0x42::Task4 { assert!( object::address_from_constructor_ref(&obj2) == @0xfab16b00983f01e5c2b7682472a4f4c3e5929fbba987958570b6290c02817df2, 1); } -} \ No newline at end of file +} From 1966e7fce8021ada5fe83d4902df23adbf3f748f Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:39:49 +0800 Subject: [PATCH 6/8] Update main.move --- task2/sources/main.move | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/task2/sources/main.move b/task2/sources/main.move index cdadda0..aeec2f7 100644 --- a/task2/sources/main.move +++ b/task2/sources/main.move @@ -12,7 +12,11 @@ module 0x42::Task2{ // 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 + let foo = Foo{ + u, + b + }; + foo } #[test] @@ -41,7 +45,11 @@ module 0x42::Task2{ // 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 + let soo = Soo{ + x, + y + }; + soo } #[test] From 32a6efe2402134fa8b527194922217a678e0c613 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:41:29 +0800 Subject: [PATCH 7/8] Update main.move --- task1/sources/main.move | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/task1/sources/main.move b/task1/sources/main.move index 724144f..a21f8f8 100644 --- a/task1/sources/main.move +++ b/task1/sources/main.move @@ -11,7 +11,10 @@ module 0x42::Task1 { // TODO // Define a function called myWallet that returns a Wallet with a balance of 1000. fun myWallet(): Wallet { - Wallet{balance : 1000} + let wallet:Wallet = Wallet{ + balance:1000 + }; + wallet } #[test] From 28f6d77c4a5a1cf8a7428957814bfda8b2c8b535 Mon Sep 17 00:00:00 2001 From: GeeekerK <105038352+GeeekerK@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:44:24 +0800 Subject: [PATCH 8/8] Update main.move --- task4/sources/main.move | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/task4/sources/main.move b/task4/sources/main.move index bbc861e..34892f2 100644 --- a/task4/sources/main.move +++ b/task4/sources/main.move @@ -3,9 +3,9 @@ // 2. Create a named object // 3. Create a sticky object module 0x42::Task4 { - use aptos_framework::object::{Self, ConstructorRef}; - - use std::signer; + use std::debug::print; + use aptos_framework::object; + use aptos_framework::object::{Object, ConstructorRef, ObjectCore}; const NAME:vector = b"myObject";