Question

In: Computer Science

Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...

Windows Forms application using Visual Basic:

Create a class called Character that a role-playing game might use to represent a character within the game.

A character should include six stats as instance variables –
strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int).
Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable.
In addition, provide a method named getStatsTotal that calculates the total of these six stats, then returns the amount as an int value.
If the total is not positive, it should be set to 0.

Create a form that can be used to create a character, assign the stats and display the stats total.

Solutions

Expert Solution

Program:

Character.vb

Public Class Character

Public strength, dexterity, constitution, intelligence, wisdom, charisma As Integer
Public totalStats As Integer

Sub New(strength1 As Integer, dexterity1 As Integer, constitution1 As Integer, intelligence1 As Integer, wisdom1 As Integer, charisma1 As Integer)
setStrength(strength1)
setDexterity(dexterity1)
setConstitution(constitution1)
SetIntelligence(intelligence1)
setWisdom(wisdom1)
setCharisma(charisma1)
End Sub

Sub setStrength(strength1 As Integer)
strength = strength1
End Sub

Sub setDexterity(deterity1 As Integer)
dexterity = deterity1
End Sub

Sub setConstitution(constitution1 As Integer)
constitution = constitution1
End Sub

Sub SetIntelligence(intelligence1 As Integer)
intelligence = intelligence1
End Sub

Sub setCharisma(charisma1 As Integer)
charisma = charisma1
End Sub

Sub setWisdom(wisdom1 As Integer)
wisdom = wisdom1
End Sub

Function getStrength()
Return strength
End Function

Function getDexterity()
Return dexterity
End Function

Function getConstitution()
Return constitution
End Function

Function getIntelligence()
Return intelligence
End Function

Function getWisdom()
Return wisdom
End Function

Function getCharisma()
Return charisma
End Function

Function getStatsTotal()
totalStats = getStrength() + getDexterity() + getConstitution() + getIntelligence() + getWisdom() + getCharisma()
If (totalStats < 0) Then
totalStats = 0
End If
Return totalStats
End Function
End Class

Form1.vb

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s, d, c, i, w, charm As Integer
s = Convert.ToInt32(txtStrength.Text)
d = Convert.ToInt32(txtDeterity.Text)
c = Convert.ToInt32(txtConstitution.Text)
i = Convert.ToInt32(txtIntelligence.Text)
w = Convert.ToInt32(txtWisdom.Text)
charm = Convert.ToInt32(txtCharisma.Text)

Dim ch As New Character(s, d, c, i, w, charm)
txtTotalStats.Text = ch.getStatsTotal()

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txtTotalStats.Enabled = False

End Sub
End Class

Screen (form):


Related Solutions

Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
how can i get the code for this problem in visual basic? Create a Windows Forms...
how can i get the code for this problem in visual basic? Create a Windows Forms applications called ISP (Internet Service Provider) Project. You must enter the number of hours for the month and select your desire ISP package. An ISP has three different subscription packages for it's customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2 per hours. Package B: For $13.95 per month 20 hours of access are provided. Additional...
Instructions: In this exercise, you’ll design a role playing character class. The Character class attributes should...
Instructions: In this exercise, you’ll design a role playing character class. The Character class attributes should include the characters’s name, gender, class* and race (can be human, elf or dwarf), and additional integer attributes of Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma. Your class should have a constructor that receives this data. For each attribute, provide setters and getters. The class should include methods that calculate and return the user’s total attributes (sums 6 attributes). Write a Java application that prompts...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class...
Must be in C#: 7. E-MAIL ADDRESS BOOK Create a Windows Forms Application with a class named PersonEntry. The PersonEntry class should have properties for a person’s name, e-mail address, and phone number. Also, create a text file that contains the names, e-mail addresses, and phone numbers for at least five people. When the application starts, it should read the data from the file and create a PersonEntry object for each person’s data. The PersonEntry objects should be added to...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Using Visual Studio in C#; create a grading application for a class of ten students. The...
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: •...
----------------------------------------------------------------------------------------------- Create a class called MathOperations that a teacher might use to represent the basic type...
----------------------------------------------------------------------------------------------- Create a class called MathOperations that a teacher might use to represent the basic type of mathematical operations that may be performed. The class should include the following: Three double private variables as instance variables, number1, number2, and result. Your class should have a default constructor that initializes the three instance variables to zero. Your class should also have a constructor that initializes the two instance variables (number1 and number2) to the value entered by the user from keyboard....
NOTE: This is done using Visual Basic. Create an application named You Do It 2. Add...
NOTE: This is done using Visual Basic. Create an application named You Do It 2. Add a text box, a label, and a button to the form. Enter the following three Option statements above the Public Class clause in the Code Editor window: Option Explicit On, Option Strict Off, and Option Infer Off. In the button’s Click event procedure, declare a Double variable named dblNum. Use an assignment statement to assign the contents of the text box to the Double...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT