Semester 1, 2023 - SENG1120/SENG6120 Assignment 1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Discipline of Computing and Information Technology
Semester 1, 2023 - SENG1120/SENG6120
Assignment 1
Due: Sunday 2 April 2023 @ 23:59
Submission method: ZIP file via Canvas
NOTE: Important information about submission and code specifics are at the end of this assignment specification. Please read andfollow this information.
INTRODUCTION
You are required to build the infrastructure to manipulate data related to playing cards such that you can
play a rudimentary version of the Game of War (War (card game) - Wikipedia). It is not necessary for you to understand the rules of the game to complete this assignment. Your client further specifies that you are to create a class named LinkedList to store information about the playing cards. The LinkedList will store the card’s rank (int) and suit (string), in a Node of the list, using the provided class Card. To simplify the task, a Card’s rank will be an integer with a value between 1 and 13, both inclusive, and the suit will be one of four strings, “Club”, “Spade”, “Diamond”, or “Heart” .
ASSIGNMENT TASK [SENG1120: 100 marks; SENG6120: 80 marks]
You are required to use a linked list, as discussed in lectures, to create your own implementation of the LinkedList class. It will use instances of Node to store instances of value_type (in this assignment, each Node will be used to store an instance of Card).
The LinkedList class will be used by a main program (LinkedListDemo.cpp). The main program and makefile will be provided as part of the assignment. You will need to design LinkedList and Node in a way that it communicates seamlessly with the main program and the class Card provided, and compiles with the makefile also supplied. Please refer to the lecture slides and recordings for guidance on how to implement both classes and be sure to use best practices in your design and implementation.
For SENG6120 students, or SENG1120 students who want to be challenged more, there is an extra requirement [20 marks]:
• Implement the member method void order () inside LinkedList. That method will order the cards according to their rank in ascending order. For two cards with equal ranks, you should place them in the order they were encountered in the list. This is referred to as a stable ordering. For example, [(3, Spade), (2, Club), (2, Diamond)] should be sorted as [(2, Club), (2, Diamond), (3, Spade)]. Furthermore, [(2, Diamond), (2, Club), (3, Spade)] would be incorrect. You are NOT ALLOWED to manipulate the contents of the Node’s value_type variable. You can only manipulate the pointers of the nodes (i.e., the next and previous pointers) to move them around until the list is ordered. In addition, you are NOT ALLOWED to instantiate new nodes in the implementation of the method void order().
For SENG6120 students, this question is required. Your assignment total will still be out of 100, with the first task reduced in weight to maintain a total of 100. For SENG1120 students, this is not required but a correct implementation for this question will result in a bonus of up to 20 marks. Note that, SENG1120 students cannot achieve a grade higher than 100, even with successful completion of this question.
SUBMISSION
Make sure your code works with the files supplied, and DO NOT change them (except for the uncommenting of the Bonus Question for SENG6120, of if you want to try it for SENG1120). For marking, we will add the main file and the Card class to the project and compile everything using the makefile, together with your own files. If it does not compile or run, unfortunately your mark will be zero.
Your submission should be made using the Assignments section of the course Canvas site. Incorrectly submitted assignments will not be marked. You should provide the .h and .cpp files related to the LinkedList and Node classes only. Also, if necessary, provide a readme.txt file containing instructions for the marker. Each program file should have a proper header section including your name, the course code, and your student number. In addition, your code should be properly documented, as discussed in lecture.
Remember that your code should compile and run correctly using Cygwin. There should be no segmentation faults or memory leaks during or after the execution of the program. Please see the accompanying marking criteriafor an indicative (but notfinal) guideline to how you will be evaluated.
Compress all your files into a single .zip file and submit it in by clicking in a link that will be created in the Assignments section on Canvas. DO NOT USE RAR or any compression format other than ZIP. Late submissions are subject to the rules specified in the Course Outline.
This assignment is worth 15% of your final grade for the course (inclusive of bonus marks for SENG1120).
Compiling and running your files together with the demo file provided should output the following result (assuming you are completing the SENG6120/Bonus Question):
krh943@CES214-3PWM2T3 ~/A1
$ make clean
rm -rf *.o core
krh943@CES214-3PWM2T3 ~/A1
$ make
g++ -c -Wall -std=c++98 -c LinkedListDemo.cpp
g++ -c -Wall -std=c++98 -c LinkedList.cpp
g++ -c -Wall -std=c++98 -c Node.cpp
g++ -c -Wall -std=c++98 -c Card.cpp
g++ LinkedListDemo.o LinkedList.o Node.o Card.o -o assignment1
krh943@CES214-3PWM2T3 ~/A1
$ ./assignment1.exe
Starting Lists:
Player 1: (6, Spades) (11, Diamonds) (12, Hearts) (3, Spades) (2, Clubs)
Player 2: (8, Spades) (11, Hearts) (4, Diamonds) (3, Hearts) (5, Diamonds)
Combined Card List: List is empty.
=====================================================
Removing card '(2, Clubs)' from player 1.
Removing card '(3, Hearts)' from player 2.
Concatenating the two lists into 'Combined Card List'.
Player 1: (6, Spades) (11, Diamonds) (12, Hearts) (3, Spades)
Player 2: (8, Spades) (11, Hearts) (4, Diamonds) (5, Diamonds)
Combined Card List: (6, Spades) (11, Diamonds) (12, Hearts) (3, Spades) (8, Spades) (11, Hearts) (4, Diamonds) (5, Diamonds)
=====================================================
Number of cards of suit 'Hearts': 2
Number of cards of suit 'Clubs': 0
Highest rank of suit 'Hearts': 12
Highest rank of suit 'Clubs': -1
Average card rank: 7.5
=====================================================
Playing 3 rounds of war
Round 1
Player 1's card: (6, Spades)
Player 2's card: (8, Spades)
Player 2 wins!
Round 2
Player 1's card: (11, Diamonds)
Player 2's card: (11, Hearts)
It's a tie! Drawing next card for each player.
Player 1's card: (12, Hearts)
Player 2's card: (4, Diamonds)
Player 1 wins!
Round 3
Player 1's card: (3, Spades)
Player 2's card: (5, Diamonds)
Player 2 wins!
Hands after playing
Player 1: (11, Diamonds) (11, Hearts) (12, Hearts) (4, Diamonds)
Player 2: (6, Spades) (8, Spades) (3, Spades) (5, Diamonds)
=====BONUS QUESTION======
Ordering the two hands by rank.
Player 1: (4, Diamonds) (11, Diamonds) (11, Hearts) (12, Hearts)
Player 2: (3, Spades) (5, Diamonds) (6, Spades) (8, Spades)
The program has finished.
2023-03-31