Professional Documents
Culture Documents
(Android)
By
Maaz Khan
(14-Arid-0668)
BS(CS)
August 2018
i
Solitaire Game
Submitted By
Maaz Khan
(14-Arid-0668)
Supervised By
Mr.Zeeshan
August 2018
ii
CERTIFICATE
It is certified that the contents and form of thesis entitled Solitaire Game submitted by
Maaz Khan have been found satisfactory for the requirement of the degree.
SUPERVISORY COMMITTEE
PROJECTSUPERVISOR:
Mr.Zeeshan
REPORTCOORDINATOR:
Ms. Kainat
WRITUP COMMITEEHEAD:
iii
ACKNOWLEDGMENT
All praise to Allah which is unique, the most Beneficent and most merciful. I
really thankful to Allah who gives me the knowledge and Wisdom. Furthermore, a
very special thanks to my parents, especially my mother who always encourage me
and pray for me. I am most grateful to my project supervisor Mr. Zeeshan for the
guidance, inspiration and constructive suggestion that helped me in the preparation
of this project. I greatly acknowledged him for kind help , best co-operation and
valuable suggestion. I am also thankful to my fellows, who helped me.
Maaz Khan
iv
ABSTRACT
Most of the People Play Games to relax their mind and this game is the best
source of it .Every kind of user can play this game, this is not made for any specific
kind of user. This Game can help both adults and children to improve their motor
skills.
v
TABLE OF CONTENTS
Contents Page No:
ACKNOWLEDGEMENT .................................................................................................. iv
ABSTRACT ..........................................................................................................................v
TABLE OF CONTENTS .................................................................................................... vi
LIST OF FIGURES .......................................................................................................... viii
CHAPTER 1- INTRODUCTION
1.1 Introductory Background ............................................................................................01
1.2 Purpose and Advantages .............................................................................................01
1.3 Objectives and Scope ..................................................................................................01
CHAPTER 2- BACKGROUND
CHAPTER 3- DESIGN
CHAPTER 4- IMPLEMENTATION
4.1 Tools and Technology..................................................................................................11
4.2 Pseudo Code.................................................................................................................12
4.3 Screen Shots .................................................................................................................20
vi
CHAPTER 5- FUTURE DIRECTION
5.1 Future Direction ...........................................................................................................30
5.2 Limitation.....................................................................................................................30
5.3 Conclusion ...................................................................................................................30
REFERENCES .................................................................................................................31
ANNEXURE .....................................................................................................................32
viii
LIST ListOF
of Figures FIGURES
ix
CHAPTER 1
INTRODUCTION
1
CHAPTER 2
BACKGROUND
This chapter contains background about this project and related projects that was developed in
the past by BIIT student. This chapter also contains discussion about design of the project and also
related software available in the market.
You can drag and drop cards and partial stacks if you want to. You can drag and drop cards and
partial stacks if you want to. Once you get all the cards ready to go in the stacks, the Auto Play
button appears to quickly move all your cards onto the Aces and to victory. Draw 3 cards at a time,
or change to draw 1 at a time if you want an easier game. and intuitive controls - Just tap on a card
or stack and watch as it magically moves where.
No. 1 Solitaire game in over 70 stores worldwide. Get immersed in this uniquely styled version
of Solitaire. With its natural card layout, feature rich content and polished visual style Simply
Solitaire HD is the only Solitaire game you need on your iPhone, iPod Touch and i-Pad. Simply
Solitaire lets you customize your game with unique card backs and backgrounds, adjustable deck
position and rotatable screen orientation giving you the freedom to play Solitaire how you want.
2
2.1.2 Landscape
Landscaping refers to any activity that modifies the visible features of an area of land including:
living elements. In this application user play game in different styles Landscape style is one of them,
in which cards will display as like other styles.
2.1.3 Portrait
3
Figure 2.2: Representation of Portrait Styles
Game Level
This game has 30 levels. Level 1 to level 10 is one suit spider solitaire which means as
the king of all solitaire games. One must be skilled at manipulating the cards they've been dealt
with. Level 11 to level 20 is two suit spider solitaire. Level 21 to Level 30 is four suit spider
solitaire which means is a card game that uses two decks of cards. The level design is from easy
to difficulty.
4
Figure 2.3: Representation of Levels of Game
Solitaire Deluxe
5
• Classic Solitaire (Klondike)
• Free cell
• Spider Solitaire
• 9 GREAT games in all
• Playable in landscape AND portrait mode
• Undo Button
Classic Solitaire (known only as simply “Solitaire” by some, and “Klondike Solitaire”. Classic Solitaire
is a game of sorting cards. You move cards between columns in an attempt to put them in order into 4
piles of cards separated by suit. If you like solitaire games, you're going to love this app. The classic
solitaire game plus the ability to control card movements naturally by just swiping or tapping the cards
on your iPhone/iPod touch/iPad. Think you have the best solitaire score around? You can check the
Game Center leaderboard to see how your solitaire skills stack up against players all around the world.
o Unlimited hints
o Unlimited undo
o Klondike
o Custom backgrounds
o Autocomplete
6
CHAPTER 3
DESIGN
The most important part of the application is design phase, in this chapter we'll discuss about
what are the requirements, functional requirements and non functional requirements and how to
gather requirements, Conceptual Diagram, Data Flow Diagram and Entity Relationship Diagram.
7
Performance Requirements
This system is full of speed and accuracy, there is no unwanted delays in the Game and user
does not have to wait for any response.
Availability
User can play this game anytime because it does not need any internet connection.
User Friendly
The structure of this game is completely all according to the need of users. It provides the
best end to end user and system interaction. User can change the game according to its own setting
which allows user to set all the structure according to itself i.e like changing the card colors,
changing the background, hiding the hint option for difficulty etc.
A data flow diagram is a graphical representation of the "flow" of data through an information
system, modeling its process aspects. A DFD is often used as a preliminary step to create an
overview of the system without going into great detail, which can later be elaborated. DFDs can also
be used for the visualization of data processing.
Level 0
CLICK Solitaire
USER Game
RESPONSE
This is the first level of application in which user will request application and application will
respond to the user request.
8
Level 1
In this level the overall working of the application and all actions of users are showed clearly.
Users can Play, undo, see Statistics, do settings and load and save.
9
3.3.1 Conceptual Diagram
A conceptual diagram is a visual representation of a system, made of the composition of
concepts which are used to help people know, understand, or simulate a subject the model
represents. It is also a set of concepts. The below mentioned diagram is describing how Solitaire
Game works:
Conceptual Diagram
In (Figure 3.10) the overall working of application is showed in simple pictorial form to help general
people and client to understand how the application works. As showed in figure the application
works by getting user request, the user will request to the application for whatever actions he/she
want to perform the application further requests to the internal storage and only goes to the database
if the user have to load and save the game.
10
CHAPTER 4
IMPLEMENTATION
To develop any application you have to use some tools and technologies, we’ll discuss
different tools and technologies used to develop the BIIT Digital Library & Lesson Plans.
Language Java
Android Studio
Android is an operating system developed by Google, based on a modified version of the Linux kernel
designed for touchscreen mobile devices such as smartphones and tablets. Android Studio is the
official integrated development environment for Google's Android operating system, built on Jet
Brains' Intelli IDEA software and designed specifically for Android development.
SQL Lite
11
4.2 Pseudo Code
repeat n times
int arr;
print arr[i];
12
Code of Main Screen
13
Output
Movement Of Cards
14
Using the operating system delay the program
End loop
End if
Do while iLow<=iHigh
15
If Target = DataArray(Middle) then
bFound = true
exit do
I High = (iMiddle - 1)
else
iLow = (iMiddle + 1)
end if
16
17
Figure 2.8: Representation of Movement of cards
18
Output
19
4.2 Screen Shots
(Splash Screen)
In (Figure 4.9) the Splash screen of application is shown, it is used in this application to make it
more interactive and so that the user can feel more excited after seeing the interactive splash screen
at the start.
20
(Main Screen)
In (Figure 4.10) the Main screen of the game is showed, different cards and structure of the game is
being presented at the main screen. User can see and evaluate the game by this and the main screen is
user friendly and attractive.
21
(Movement of Cards)
In (Figure 4.12) the movement of cards is being shown after making some possible moves, you can
see that there is an undo option and support option. User can undo its move up to its first move and
can see the hints for the possible moves in support option.
22
(General Statistics)
In (Figure 4.13) the Statistic of user is shown in which the General tab is being displayed. User can
see its progress in the game so far and can see all the stats of the present match.
23
(High Scores Statistics)
In (Figure 4.13) the Statistic of user is shown in which the High scores tab is being displayed. User
can see the high Scores of all the games played and the user can try to achieve the new high score.
24
(Menu Screen)
In (Figure 4.17) all the possible options of the menu are given. User can start a new game, save its
game, loads it previous game, close the game, ask for a re deal. Menus are made according to the
user requirements.
25
(Save Game Screen)
In (Figure 4.18) the save game dialog box can be seen. User can save its game according to its own
title and can retrieve the same game later on in a load game option.
26
(Loaded Games )
In the (Figure 4.20) the loads of the user can be seen, user have loaded the games with these names
and the user can now retrieve its game by selecting any of its previously saved games.
27
(Support Option)
In (Figure 4.20) The Support dialog box of the game has been shown. User can see the possible hints
on the possible moves and if the user is new to the game then there is a Game Rule option which can
be helpful for the user to Learn more about the game.
28
(Settings Screen)
29
CHAPTER 5
CONCLUSION
5.2 Limitations
Application is dependent to Android smart phones/devices only.
5.3 Conclusion
The Solitaire Game is made for general users and it very appreciated among every kind of user, it can
be access from everywhere and from every android device. The main Purpose of this gaming
application is to develop a game that will entertain user to some extent. This game is made
considering many objectives. User can play, achieve high scores, Undo its moves, saves and loads
games. Guides user with how to play option. To Provides user the possible hints. Allows user to
change the game setting according to its own choice. These are all the features of the Solitaire Game.
It is concluded that the application works well and meets with all the requirements of application.
The Game is tested well and errors are debugged. The application is simultaneously accessed from
more than one system and simultaneous Accessed from more than one place is tested.
The application works fine and further enhancements can be made to the application, so that the
application remains attractive and useful to existing application.
30
REFERENCES
[1] King Klan , "Assigning images to the Cards", (27th Sept, 2017) [ Online link:
https://stackoverflow.com/questions/46444468/how-to-assign-unique-images-to-each-card-
in-my-deck-of-cards-in-android-studio ] (accessed 11th April, 2018).
[2] Android Developers, “ Create a Card Based Layout “ , ( November 8, 2017) [ Online Link
:https://developer.android.com/guide/topics/ui/layout/cardview] (accessed 14th April, 2018).
[4] User 3665376, "Working on the Cars Design", (20th Sep, 2014), [Online link:
https://stackoverflow.com/questions/25810586/android-layout-how-to-implement-a-ui-
similar-to-deck-of-cards],(accessed 14th May, 2018).
` [6] TihomarRadeff, "Working on Deck Of cards ", (Jan 25th, 2017), [online link:
https://www.youtube.com/watch?v=1qHVvu4BUtk], (accessed 24h May,2018).
31
ANNEXEURE
ANNEXURE A
Main Screen
import android.graphics.PointF;
import java.util.ArrayList;
import java.util.List;
if (cards == null) {
return;
}
if (cards == null) {
return;
}
prefs.saveCards(list);
}
33
view.setImageBitmap(background);
}
34
public void flipWithAnim() {
if (isUp()) {
isUp= false;
scores.undo(this, getStack());
animate.flipCard(this, false);
} else {
isUp= true;
scores.move(this, getStack());
recordList.addFlip(this);
animate.flipCard(this, true);
}
}
public booleantest(Stack destination) {
if (prefs.isDeveloperOptionMoveCardsEverywhereEnabled()){
return true;
}
public booleanisFirstCard() {
return getStack().getCard(0) == this;
}
public intgetIndexOnStack() {
return getStack().getIndexOfCard(this);
}
public booleanisUp() {
return isUp;
}
public intgetId() {
return id;
}
public intgetValue() {
return value;
}
public Stack getStack() {
return stack;
}
public void setStack(Stack stack) {
this.stack= stack;
}
35
public float getX() {
return view.getX();
}
public intgetStackId() {
return stack.getId();
}
36
Output
37
ANNEXURE B
Movement Of cards
package de.tobiasbielefeld.solitaire.games;
import android.content.Context;
import android.widget.RelativeLayout;
import java.util.ArrayList;
import de.tobiasbielefeld.solitaire.classes.Card;
import de.tobiasbielefeld.solitaire.classes.CardAndStack;
import de.tobiasbielefeld.solitaire.classes.Stack;
protected intwhichGame;
public Klondike() {
setNumberOfDecks(1);
setNumberOfStacks(15);
setTableauStackIDs(0,1,2,3,4,5,6);
setFoundationStackIDs(7,8,9,10);
setDiscardStackIDs(11,12,13);
setMainStackIDs(14);
whichGame= 1;
setMixingCardsTestMode(testMode.ALTERNATING_COLOR);
setNumberOfRecycles(PREF_KEY_KLONDIKE_NUMBER_OF_RECYCLES,
DEFAULT_KLONDIKE_NUMBER_OF_RECYCLES);
toggleRecycles(prefs.getSavedKlondikeLimitedRecycles());
}
38
public void setStacks(RelativeLayoutlayoutGame, booleanisLandscape,
Context context) {
public booleanwinTest() {
39
for (inti = 7; i <= 10; i++) {
if (stacks[i].getSize() != 13) {
return false;
}
}
return true;
}
prefs.saveKlondikeVegasDrawModeOld(whichGame);
if (prefs.getSavedKlondikeVegasDrawModeOld(whichGame).equals("1")) {
moveToStack(getMainStack().getTopCard(), stacks[13],
OPTION_NO_RECORD);
stacks[13].getCard(0).flipUp();
} else {
for (inti = 0; i <3; i++) {
moveToStack(getMainStack().getTopCard(), stacks[11 + i],
OPTION_NO_RECORD);
stacks[11 + i].getCard(0).flipUp();
}
}
public intonMainStackTouch() {
booleandeal3 =
prefs.getSavedKlondikeVegasDrawModeOld(whichGame).equals("3");
if (getMainStack().getSize() >0) {
if (deal3) {
intsize = min(3, getMainStack().getSize());
ArrayList<Card>cardsReversed = new ArrayList<>();
ArrayList<Stack>originReversed = new ArrayList<>();
ArrayList<Card> cards = new ArrayList<>();
ArrayList<Stack> origin = new ArrayList<>();
while (!stacks[12].isEmpty()) {
40
cards.add(stacks[12].getTopCard());
origin.add(stacks[12]);
moveToStack(stacks[12].getTopCard(), stacks[11], OPTION_NO_RECORD);
}
while (!stacks[13].isEmpty()) {
cards.add(stacks[13].getTopCard());
origin.add(stacks[13]);
moveToStack(stacks[13].getTopCard(), stacks[11], OPTION_NO_RECORD);
}
if (!stacks[12].isEmpty()) {
stacks[12].getTopCard().view.bringToFront();
}
if (!stacks[13].isEmpty()) {
stacks[13].getTopCard().view.bringToFront();
41
}
cardsReversed.clear();
originReversed.clear();
for (inti = 0; i <cards.size(); i++) {
cardsReversed.add(cards.get(cards.size() - 1 - i));
originReversed.add(origin.get(cards.size() - 1 - i));
}
recordList.add(cardsReversed, originReversed);
} else {
moveToStack(getMainStack().getTopCard(), stacks[13]);
}
return 1;
}
return 2;
}
return 0;
}
public booleanautoCompleteStartTest() {
42
for (inti = 0; i <7; i++) {
if (stacks[i].getSize() >0 && !stacks[i].getCard(0).isUp()) {
return false;
}
}
if (prefs.getSavedKlondikeVegasDrawModeOld(whichGame).equals("3")||
hasLimitedRecycles()) {
if (getMainStack().getSize()>0 || stacks[11].getSize()>0 ||
stacks[12].getSize()>0 || stacks[13].getSize()>1){
return false;
}
}
return true;
}
public CardAndStackhintTest() {
Card card;
if (origin.isEmpty()) {
43
continue;
}
card = origin.getFirstUpCard();
if (card.test(stacks[j])) {
return new CardAndStack(card, stacks[j]);
}
}
}
card = origin.getTopCard();
if (!hint.hasVisited(card)) {
for (intj = 7; j <= 10; j++) {
if (card.test(stacks[j])) {
return new CardAndStack(card, stacks[j]);
}
}
}
return null;
}
44
public Stack doubleTapTest(Card card) {
if (card.isTopCard()) {
for (intj = 7; j <11; j++) {
if (card.test(stacks[j])) {
return stacks[j];
}
}
}
if (card.test(stacks[j])) {
return stacks[j];
}
}
return null;
}
public CardAndStackautoCompletePhaseTwo() {
return null;
}
for (inti=0;i<originIDs.length;i++){
if (originIDs[i] >=11 &&originIDs[i]<=13 &&destinationIDs[i] <=10){
return 45;
}
}
return 0;
}
if (gameLogic.hasWon()){
return;
}
booleandeal1 =
prefs.getSavedKlondikeVegasDrawModeOld(whichGame).equals("1");
checkEmptyDiscardStack(getMainStack(),stacks[11], stacks[12],
stacks[13], deal1);
}
46
public static void checkEmptyDiscardStack(Stack mainStack, Stack
discard1, Stack discard2, Stack discard3, booleandeal1){
if(!cards.contains(discard2.getTopCard())) {
cards.add(discard2.getTopCard());
origin.add(discard1);
}
}
if(size >0) {
moveToStack(discard1.getTopCard(), discard3, OPTION_NO_RECORD);
if (!cards.contains(discard3.getTopCard())) {
cards.add(discard3.getTopCard());
origin.add(discard1);
}
}
if (!discard3.isEmpty()) {
discard3.getTopCard().view.bringToFront();
}
recordList.addToLastEntry(cardsReversed, originReversed);
}
while (!discard2.isEmpty()) {
cards.add(discard2.getTopCard());
origin.add(discard2);
moveToStack(discard2.getTopCard(), discard1, OPTION_NO_RECORD);
}
if (discard1.getSize() >1) {
moveToStack(discard1.getCardFromTop(1), discard2, OPTION_NO_RECORD);
if (!cards.contains(discard2.getTopCard())) {
cards.add(discard2.getTopCard());
origin.add(discard1);
}
}
if (!discard1.isEmpty()) {
moveToStack(discard1.getTopCard(), discard3, OPTION_NO_RECORD);
if (!cards.contains(discard3.getTopCard())) {
cards.add(discard3.getTopCard());
origin.add(discard1);
}
}
48
if(!discard2.isEmpty()) {
discard2.getTopCard().view.bringToFront();
}
if (!discard3.isEmpty()) {s
discard3.getTopCard().view.bringToFront();
}
recordList.addToLastEntry(cardsReversed, originReversed);
}
}
}
49