Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'M STUCK ON GETTING MY PROGRAM TO FUNCTION. I\'M TRYING TO SELECT THE CHECK BO

ID: 3594114 • Letter: I

Question

I'M STUCK ON GETTING MY PROGRAM TO FUNCTION.

I'M TRYING TO SELECT THE CHECK BOXES, RETURN WHETHER SEAT IS AVAILABLE, AND GREY OUT SELECT CHECKED BOXES.

I've checked my program simple as you well see I would like a second set of eyes to see where my program could be modified for better preformance so it runs correctly. Thank you again for your help.

Must use a simple GUI with radio buttons to select a business or economy class (you can use Add button to make selection.)
Use checkboxes to represent seats (obviously, selected are checked.)
Do your own study on checkboxes and radiobuttons.
Selections in each class are sequential (first available seat in class).
Basically, make UI for the provided console example.
Use separate classes for seats selection logic and GUI front-end.

I'm not sure on the best way to resolve some of my code errors as provided below. I'm keeping it simple since it's just the beginning of the project.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AirlineReservation
{
    public partial class frmAirLineReservationGUI : Form
    {
        Reserver reserver = null;


        private void frmAirLineReservationGUI_Load(object sender, EventArgs e)
        {
            this.reserver = new Reserver();
            InitializeComponent();
        }
        private void btnReserve_Click(object sender, EventArgs e)
        {
            if (rdbnFirstClass.Checked)
            {
                handleFirstClass();
            }
            else
            {
                handleEconomyClass();
            }
        }

        private void handleFirstClass()
        {
            if (reserver.isFirstClassAvailable())
            {
                int seat = reserver.reserverFirstClassAnySeat();

            }
            else if (reserver.isEconomyClassAvailable())
            {
                MessageBox.Show("First Class is not available choose economy.");

            }
            else
            {
                MessageBox.Show("All seats are taken next fligh 3 hours.");
            }

        }
       
        public class Reserver //IReserver class table.
        {
            private bool[] frstseats = new bool[5];
            private bool[] ecoseats = new bool[5];

            public bool isFirstClassAvailable()
            {
                foreach(var seat in frstseats)
                {
                    if (seat == false)
                    {
                        return true;
                    }
                }
                return false;
            }

            public bool isEconomyClassAvailable()
            {
                foreach(var seat in ecoseats)
                {
                    if(seat == false)
                    {
                        return true;
                    }
                }   return false;

            }

            internal int reserverFirstClassAnySeat()
            {
                throw new NotImplementedException();
            }
        }

        public bool isEconomyClassAvailable()
        {
            for(int i = 0; i < ecoseats.length; i++)
            {
                if(ecoseats[i] == false)
                {
                    return true;
                }
            }
            return false;
        }
       
        private bool [] getAllFirstClassSeats()
        {
            return frstSeats;
        }
        private bool [] getAllEconomySeats()
        {
            return ecoseats;
        }
    }  


}

AirlineReservation Frst Class O Econom y Class 10 Exit Error List Entire Solution |C 5 Errors |||A0Warnings ||O 0 of 9 Messages Search Error List Code Description CS0103 CS0103 CS0103 CS0103 Project File Line S.. The name 'handleEconomyClass' does not exist in the current context The name 'frstSeats' does not exist in the current context The name'ecoseats' does not exist in the current context The name'ecoseats' does not exist in the Active 103 Active 1 Active AirlineReservation Form1.cs AirlineReservation Form1.cs AirlineReservation Form1.cs AirlineReservation Form1 02ACTV

Explanation / Answer

Hi,

I have corrected some of the semantic errors and typing error in the code. Below is the corrected code-

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace AirlineReservation
{
public partial class frmAirLineReservationGUI : Form
{
Reserver reserver = null;
  

private void frmAirLineReservationGUI_Load(object sender, EventArgs e)
{
Reserver reserver = new Reserver();
InitializeComponent();
  
}
private void btnReserve_Click(object sender, EventArgs e)
{
if (rdbnFirstClass.Checked)
{
handleFirstClass();
}
else
{
MessageBox.Show("First Class is not available choose economy.");
}
}
private void handleFirstClass()
{
if (reserver.isFirstClassAvailable())
{
int seat = reserver.reserverFirstClassAnySeat();
}
else if (reserver.isEconomyClassAvailable1())
{
MessageBox.Show("First Class is not available choose economy.");
}
else
{
MessageBox.Show("All seats are taken next fligh 3 hours.");
}
}

public class Reserver //IReserver class table.
{
public bool[] frstseats = new bool[5];
public bool[] ecoseats = new bool[5];
public bool isFirstClassAvailable()
{
foreach (var seat in frstseats)
{
if (seat == false)
{
return true;
}
}
return false;
}
public bool isEconomyClassAvailable()
{
foreach (var seat in ecoseats)
{
if (seat == false)
{
return true;
}
} return false;
}
internal int reserverFirstClassAnySeat()
{
throw new NotImplementedException();
}

public bool isEconomyClassAvailable1()
{
for (int i = 0; i < ecoseats.Length; i++)
{
if (ecoseats[i] == false)
{
return true;
}
}
return false;
}


private bool[] getAllFirstClassSeats()
{
return frstseats;
}
private bool[] getAllEconomySeats()
{
return ecoseats;
}
}

private void checkBox8_CheckedChanged(object sender, EventArgs e)
{

}
}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote