Wednesday, May 15, 2019

How Can We Do My Python Assignment for You?


My very first assignment at University was to program a game of 21, although it was a cut down version. The assignment was in Pascal, so I have converted the code into Python to demonstrate a simple assignment. The basic rules of BlackJack (21, Pontoon) are that you have a deck of cards, and face cards count as 10 (Jack, Queen, King), and the Ace can count as 1 or 11. You see your cards, but not the dealers (you see one of the dealers cards) and you decide whether to stop where you are or to draw a new card. Once you have finished, the dealer takes their turn, and will draw if the value of the hand is less than 17. I’ve not included comments in the code, but I would do if it was a real assignment.
# Blackjack (21 or Pontoon)

import random

class Card:

    deck = []

    def __init__(self, rank, suit):
        if rank == "1":
            rank = "10"
        self.rank = rank
        self.suit = suit
        if rank in "JQK":
            self.val = 10
        elif rank == "A":
            self.val = 11
        else:
            self.val = int(rank)

    def __str__(self):
        return "%s%s" % (self.rank, self.suit)

    def __repr__(self):
        return str(self)

class Deck:

    def __init__(self):
        self.__deck = [Card(rank, suit) for suit in "CDHS" for rank in "234567891JQKA"]
        self.shuffle()

    def draw(self):
        card = self.__deck[self.__index]
        self.__index += 1
        return card

    def shuffle(self):
        random.shuffle(self.__deck)
        self.__index = 0

    def show_hand(self, hand):
        return "%s (%d)" % (",".join(str(card) for card in hand), self.score(hand))

    def score(self, hand):
        total = 0
        aces = 0
        for card in hand:
            total += card.val
            if card.val == 11:
                aces += 1
        while total > 21 and aces:
            total -= 10
            aces -= 1
        return total


def main():
    pot = 20
    while pot > 0:
        bet = int(input("You have %d available, how much do you want to bet? (0 to end) " % pot))
        if not bet:
            break
        if bet < 1:
            bet = 1
        if bet > pot:
            bet = pot
        deck = Deck()
        player = [deck.draw(), deck.draw()]
        dealer = [deck.draw(), deck.draw()]
        pot -= bet
        while True:
            print("You have:", deck.show_hand(player))
            print("Dealer shows:", dealer[0])
            move = input("(s)tick, (d)raw: ")
            if move in "sS":
                break
            if move in "dD":
                player.append(deck.draw())
            player_score = deck.score(player)
            if player_score > 21:
                break

        player_score = deck.score(player)
        if player_score > 21:
            print("Player bust")
            continue

        dealer_score = deck.score(dealer)
        print("Dealer has:", deck.show_hand(dealer))
        while dealer_score < 17:
            dealer.append(deck.draw())
            dealer_score = deck.score(dealer)
            print("Dealer has:", deck.show_hand(dealer))

        if dealer_score > 21:
            print("Dealer bust")
            pot += bet * 2
        elif player_score == dealer_score:
            print("Draw")
            pot += bet
        elif dealer_score > player_score:
            print("Dealer wins")
        else:
            print("You win")
            pot += bet * 2

    print("\n\nYou ended up with $%d" % pot)


main()


We can work on assignments far more complex than this, and in multiple programming languages. I’ve used Python to write GUI programs, web servers, games (using Pygame) and even a simple compiler.

You can rely on Programming Assignment Helper if you need someone to do my Python homework.

Tuesday, May 14, 2019

How We Can “Do My Java Assignment” for You?


Java is useful for cross platform development of GUI applications, as C++ does not come with any GUI library included although there are a few cross platform GUI’s that can be used. Developing an application to be cross platform, means you are not taking advantage of all of the facilities available, and the application will not appear as polished as one written for the native environment, it does offer the advantage of file and data compatibility between the different platforms.
The biggest challenge in writing something that works on all platforms is to make it feel as close to a native application as possible, which means that keyboard shortcuts need to be different depending on the current platform. We have experts with multiple machines, so if you need a program that runs on Mac and Windows we can find someone who can do that.
Java is not just used on desktop computers, but can be used on phones, Android uses a version of Java. Although the GUI is very different than the one used on desktops, a different model is used and even the format of the instructions in the virtual machine is different.
There are 2 main ways of writing a GUI on desktop Java, which is Swing and JavaFX which is similar to developing in HTML. JavaFX applications look more modern than Swing but it has been deprecated and no longer being supported by Oracle.
Java provides a useful introduction to object orientated programming, with a simpler model than C++. The homework assignments involving object orientated programming are normally simplified from a real world problem.
If you are looking for help with any type of Java assignment, from basic code with just variables, and if statements and loops or more complicated code such as a GUI, then we have the experts for you with over a decade of experience in Java. Our experts are from all over the world, including Australia, America and Europe and we offer a 24/7 service, although the best time for new quotes is between 8AM-11PM PST.
You can rely on Programming Assignment Helper if you need someone to “do my Java homework”.