as an example of code reuse take the rectangle.vb class and reuse it in two applications that deal with 1 paint one gallon of paint will cover 400 square feet
it costs $15 a gallon
2 flooring prices per square foot are: $1.59 for vinyl $5.79 for high-end hardwood $2.29 for bamboo
these are 2 projects having trouble with
'Name: Rectangle.vb
' Programmer: <Hello> on <3/9/2030>
Option Explicit On
Option Strict On
Option Infer Off
Public Class Rectangle
Private intLength As Integer
Private intWidth As Integer
Public Property Length As Integer
Get
Return intLength
End Get
Set(value As Integer)
If value > 0 Then
intLength = value
Else
intLength = 0
End If
End Set
End Property
Public Property Width As Integer
Get
Return intWidth
End Get
Set(value As Integer)
If value > 0 Then
intWidth = value
Else
intWidth = 0
End If
End Set
End Property
Public Sub New()
intLength = 0
intWidth = 0
End Sub
Public Sub New(ByVal intL As Integer, ByVal intW As Integer)
Length = intL
Width = intW
End Sub
Public Function GetArea() As Integer
Return intLength * intWidth
End Function
End Class
Note: Done accordingly. Please comment for any problem. Please
Uprate. Thanks.
Download Code:
https://drive.google.com/open?id=1vlSPgYkbxkyZmmv1Hww6bjqfhM-5KuFM
Code:
Module Module1
Sub paint(rect As Rectangle)
Dim cost As Double
cost = rect.GetArea() / 400.0 * 15
Console.WriteLine("Cost of painting :$" & cost)
End Sub
Sub flooring(rect As Rectangle)
Dim cost As Double
cost = rect.GetArea() * 1.59
Console.WriteLine("Cost of vinyl flooring :$" & cost)
cost = rect.GetArea() * 5.79
Console.WriteLine("Cost of high-end hardwood flooring :$" &
cost)
cost = rect.GetArea() * 2.29
Console.WriteLine("Cost of bamboo flooring :$" & cost)
End Sub
Sub Main()
Dim length, width As Integer
Console.Write("Please give length :")
length = Integer.Parse(Console.ReadLine())
Console.Write("Please give width :")
width = Integer.Parse(Console.ReadLine())
Dim rectangle As Rectangle = New Rectangle(length, width)
'Calling paint and flooring method to calculate and print cost.We
are just passing Rectangle object
paint(rectangle)
flooring(rectangle)
Console.ReadKey()
End Sub
End Module
Output:

As an example of code reuse take the rectangle.vb class and reuse it in two applications that dea...
Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory
Maintenance Application
Source Code:
1. frmNewItem.vb
Public Class frmNewItem
Public InvItem As InvItem
Private Sub frmNewItem_Load(sender As Object, e As EventArgs)
Handles MyBase.Load
Me.LoadComboBox()
End Sub
Private Sub LoadComboBox()
cboSizeOrManufacturer.Items.Clear()
If rdoPlant.Checked Then
cboSizeOrManufacturer.Items.Add("1 gallon")
cboSizeOrManufacturer.Items.Add("5 gallon")
cboSizeOrManufacturer.Items.Add("15 gallon")
cboSizeOrManufacturer.Items.Add("24-inch box")
cboSizeOrManufacturer.Items.Add("36-inch box")
Else
cboSizeOrManufacturer.Items.Add("Bayer")
cboSizeOrManufacturer.Items.Add("Jobe's")
cboSizeOrManufacturer.Items.Add("Ortho")
cboSizeOrManufacturer.Items.Add("Roundup")
cboSizeOrManufacturer.Items.Add("Scotts")
End If
End Sub
Private Sub btnSave_Click(sender As Object, e As EventArgs)
Handles btnSave.Click
If IsValidData() Then
InvItem = New InvItem(CInt(txtItemNo.Text),...
Programming: Java: Fixing errors in code help: The errors are in square.java and rectangle.java and they both say: constructor Shape in class Shape cannot be applied to given types; required: no arguments found: String reason: actual and formal argument lists differ in length The directions say: The files Shape.java and TestArea.java have been finished already, YOU DONT ADD ANYTHING TO THESE TWO. According to the requirement, you need to modify in Square.java and Rectangle.java, respectively a. Implementing constructor with no...
In this exercise, you’ll add code to a form that converts the
value the user enters based on the selected conversion type.
The application should handle the following conversions:
1. Open the Conversions project. Display the code for the form,
and notice the rectangular array whose rows contain the value to be
displayed in the combo box, the text for the labels that identify
the two text boxes, and the multiplier for the conversion as shown
above. Note: An array...
Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...
this is for java programming Please Use Comments I am not 100% sure if my code needs work, this code is for the geometric if you feel like you need to edit it please do :) Problem Description: Modify the GeometricObject class to implement the Comparable interface and define a static max method in the GeometricObject class for finding the larger (in area) of two GeometricObject objects. Draw the UML and implement the new GeometricObject class and its two subclasses...
My assignment is to create a rectangle class in java. •Create a MyRectangleClass •There are two private instance variables, length l and width w with double data type. •There is a constructor with two parameter •There are 4 public methods which are circumference, area, getWidth, and getLength. •circumference method will return circumference to the caller.(the formula for circumference is 2 *l + 2*w ) •Area method Return the area to the caller(:l*w) •getLength method will return length to the caller....
As part of my work on a legacy C# application I've come across a novel (to me) use of an interface & concrete implementations. I can't think of any reason why you'd do the following, but I'm pretty thick, so maybe someone else can? public interface IContract { ContractImplementation1 Contract { get; } bool IsCollection { get; } bool Touched { get; set; } } public class ContractImplementation1 : IContract { public ContractImplementation1(string propertyOne, string propertyTwo,...
Create a BoxFigure class that inherits RectangleFigure class BoxFigure Class should contain:- Height instance field- Default constructor -- that calls the default super class constructor and sets the default height to 0- Overloaded constructor with three parameters (length, width and height) – that calls the two parameterized super class constructor passing in length and width passed and sets the height to passed height.- setDimension method with three parameters (length, width, height) – call the super class setDimension and pass in...
Hello I have a question. I would like to check if the code follows this requirement. Rectangle.h - A complete Rectangle Class including both declaration and definition appRectangle,cpp separate in two different files the class definition and implementation Code: rectangle.h // Rectangle class declaration. class Rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; //************************************************** // setWidth assigns a value to the width member. * //************************************************** void...