Figure 1 Instructions In this case, you will create a Visual Basic solution that
ID: 659024 • Letter: F
Question
Figure 1
Instructions
In this case, you will create a Visual Basic solution that simulates a program running on a kiosk. This program allows Buzz Advertising to generate ad sales for its weekly shopping deals booklet in a local flea market. Merchants can book their own ads by using this program. This program uses objects created from classes. Use the accompanying graphic file and the instructions below.
Requirements:
Ad price is based on the size of the ad and the location in the shopping deals booklet. Table 1 shows the ad sizes and the price relationship of each size to the base price. Table 2 shows the location markup that must be applied to the calculated price to determine the final price. Prices are calculated as follows:
* = finalprice
The base price of an ad is $225.00.
Restrictions:
Business card size ads may only be placed on interior pages. Do not allow the user to selection any location when interior page location is selected.
The outside back cover is reserved for a full page ad. Do not allow the user to select outside back cover unless full page has already been selected.
Size
Price
Full page
100% of base price
Half page
65% of base price
Quarter page
40% of base price
Business card
$35.00
Table 1 ? Price by Size
Location
Markup
Interior page
1.00
Inside front cover
1.20
Inside back cover
1.15
Outside back cover
1.40
Table 2 ? Markup by Location
Step 1: Create the Project:
Create a Visual Basic Project using the project name ?BuzzAdvertising?.
Step 2 ? Design the Form:
Design the form as shown in Figure 1. You will need three button controls, eight radio buttons, two group boxes, seven labels, and one picture box. Load the downloaded bee.jpg image into the picture box. Remove the control box because this program will run in a kiosk.
Step 3 ? Create the Ad class
Add a Class file named Ad to the project. The Ad class should have the following properties: company, telephone, run date, size, location, and price. Create a method in the Ad class that calculates the final price of an ad.
Step 4 ? Write code in the main form:
Set the size and location based on the radio button selections. Create a new Ad object, passing in the required data values to the constructor. After the Ad object has been created, call the Ad object?s calculate method to obtain the final price. Display the final price with appropriate formatting.
Step 7 ? Finish up:
Be sure to add the code for the Clear and Exit buttons.
Step 8: Save and run
Save all files, then start the application.
Figure 2
Figure 3
Size
Price
Full page
100% of base price
Half page
65% of base price
Quarter page
40% of base price
Business card
$35.00
Ad Sian G Page Hal Page Quarte Page Business card Catch the Buzz! Place your ad with Buzz Advertising for maximum exposure! Reserve your ad today: outside back cover irade back coverExplanation / Answer
The VB code behind for the form controls and events is as follows:-
Private Sub reserveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reserveButton.Click
'create the object for the class Ad_to_project
Dim ad As New Ad_to_project
'If none of location radiobutton is checked then display the message
If outsidebackRadioButton.Checked = False AndAlso insidebackRadioButton.Checked = False AndAlso insidefrontRadioButton.Checked = False AndAlso interiorRadioButton.Checked = False Then
MessageBox.Show("You should choose a location from the list", "Buzz Advertising", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
' We need to make sure all the textbox has been filled
If companyTextBox.Text = String.Empty AndAlso TelephoneTextBox.Text = String.Empty AndAlso dateTextBox.Text = String.Empty Then
MessageBox.Show("You should enter all the informations", "Buzz Advertising", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
'Determines the base price depending upon the selected ad size radio button
If fullRadioButton.Checked = True Then
ad.Size = 225.0
End If
If halfRadioButton.Checked = True Then
ad.Size = 225.0 * 0.65
End If
If quaterRadioButton.Checked = True Then
ad.Size = 225.0 * 0.4
End If
If BuisnessRadioButton.Checked = True Then
ad.Size = 35.0
End If
' Determines the mark up depending upon the selected location radio button
If outsidebackRadioButton.Checked = True Then
ad.Location = 1.4
ElseIf insidebackRadioButton.Checked = True Then
ad.Location = 1.15
ElseIf insidefrontRadioButton.Checked = True Then
ad.Location = 1.2
ElseIf interiorRadioButton.Checked = True Then
ad.Location = 1.0
End If
'Display the total price
priceLabel.Text = ad.Price.ToString("C2")
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
'close the form when the exit button of the form is clicked
Me.Close()
End Sub
End Class
Code for the Class:-
Public Class Ad_to_project
'declare all class data members
Private m_Company As String
Private m_Telephone As String
Private m_addate As String
Private m_Size As Decimal
Private m_Location As Decimal
Private m_Price As Decimal
'we need to define a constructor to initialize the data members
Public Sub New()
m_Company = ""
m_Telephone = ""
m_addate = ""
m_Size = 0.0
m_Location = 0.0
m_Price = 0.0
End Sub
'define all the setter and getter methods
Public Property Company() As String
Get
Return m_Company
End Get
Set(ByVal value As String)
m_Company = value
End Set
End Property
Public Property Telephone() As String
Get
Return m_Telephone
End Get
Set(ByVal value As String)
End Set
End Property
Public Property AdDate() As String
Get
Return m_addate
End Get
Set(ByVal value As String)
m_addate = value
End Set
End Property
Public Property Size() As Decimal
Get
Return m_Size
End Get
Set(ByVal value As Decimal)
m_Size = value
End Set
End Property
Public Property Location() As Decimal
Get
Return m_Location
End Get
Set(ByVal value As Decimal)
m_Location = value
End Set
End Property
Public Property Price() As Decimal
Get
Return m_Price
End Get
Set(ByVal value As Decimal)
m_Price = value
End Set
End Property
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.