Darma
Darma
CC#
Created by Darma on 4/23/2023 in #help
❔ Trouble with modifiers
thank you guys
14 replies
CC#
Created by Darma on 4/23/2023 in #help
❔ Trouble with modifiers
ah
14 replies
CC#
Created by Darma on 4/23/2023 in #help
❔ Trouble with modifiers
14 replies
CC#
Created by Darma on 4/23/2023 in #help
❔ Trouble with modifiers
class Lab13A
{
public static void Main(string[] args)
{
BuildingBlueprint buildingOne = new BuildingBlueprint();
BuildingBlueprint buildingTwo = new BuildingBlueprint(30, 30, .75f);

Console.WriteLine("Year 2020");
Console.WriteLine("Building 1 has " + buildingOne.Stories + " floors, " + buildingOne.Apts + " apartments, and is " + buildingOne.Occupancy * 100 + "% occupied. Full? " + buildingOne.FullyOccupied);
Console.WriteLine("Building 2 has " + buildingTwo.Stories + " floors, " + buildingTwo.Apts + " apartments, and is " + buildingTwo.Occupancy * 100 + "% occupied. Full? " + buildingTwo.FullyOccupied);

Console.WriteLine("Many years pass.");
buildingOne.Occupancy = 0.0f;
buildingTwo.Occupancy = 1.0f;
//Console.WriteLine("Building 1 has " + buildingOne.Stories + " floors, " + buildingOne.Apts + " apartments, and is " + buildingOne.Occupancy * 100 + "% occupied. Full? " + buildingOne.FullyOccupied) ;
//Console.WriteLine("Building 2 has " + buildingTwo.Stories + " floors, " + buildingTwo.Apts + " apartments, and is " + buildingTwo.Occupancy * 100 + "% occupied. Full? " + buildingTwo.FullyOccupied);
Console.WriteLine(buildingOne.Occupancy);
Console.WriteLine(buildingOne.FullyOccupied);
}
}
class Lab13A
{
public static void Main(string[] args)
{
BuildingBlueprint buildingOne = new BuildingBlueprint();
BuildingBlueprint buildingTwo = new BuildingBlueprint(30, 30, .75f);

Console.WriteLine("Year 2020");
Console.WriteLine("Building 1 has " + buildingOne.Stories + " floors, " + buildingOne.Apts + " apartments, and is " + buildingOne.Occupancy * 100 + "% occupied. Full? " + buildingOne.FullyOccupied);
Console.WriteLine("Building 2 has " + buildingTwo.Stories + " floors, " + buildingTwo.Apts + " apartments, and is " + buildingTwo.Occupancy * 100 + "% occupied. Full? " + buildingTwo.FullyOccupied);

Console.WriteLine("Many years pass.");
buildingOne.Occupancy = 0.0f;
buildingTwo.Occupancy = 1.0f;
//Console.WriteLine("Building 1 has " + buildingOne.Stories + " floors, " + buildingOne.Apts + " apartments, and is " + buildingOne.Occupancy * 100 + "% occupied. Full? " + buildingOne.FullyOccupied) ;
//Console.WriteLine("Building 2 has " + buildingTwo.Stories + " floors, " + buildingTwo.Apts + " apartments, and is " + buildingTwo.Occupancy * 100 + "% occupied. Full? " + buildingTwo.FullyOccupied);
Console.WriteLine(buildingOne.Occupancy);
Console.WriteLine(buildingOne.FullyOccupied);
}
}
14 replies
CC#
Created by Darma on 4/23/2023 in #help
❔ Trouble with modifiers
class BuildingBlueprint
{
private int numOfStories;
private int numofApts;
private float occupancy;
private bool fullyOccupied;

public BuildingBlueprint()
{
numOfStories = 10;
numofApts = 20;
occupancy = 1.0f;
fullyOccupied = true;
}

public BuildingBlueprint(int nS, int nA, float o)
{
numOfStories = nS;
numofApts = nA;
occupancy = o;

if (occupancy == 1.0f)
{
fullyOccupied = true;
}
else
{
fullyOccupied = false;
}


}
public float Occupancy
{
get { return occupancy; }
set { occupancy = value; }

}

public int Stories
{
get { return numOfStories; }
}

public int Apts
{
get { return numofApts; }
}

public bool FullyOccupied
{
get { return fullyOccupied; }
}

}
class BuildingBlueprint
{
private int numOfStories;
private int numofApts;
private float occupancy;
private bool fullyOccupied;

public BuildingBlueprint()
{
numOfStories = 10;
numofApts = 20;
occupancy = 1.0f;
fullyOccupied = true;
}

public BuildingBlueprint(int nS, int nA, float o)
{
numOfStories = nS;
numofApts = nA;
occupancy = o;

if (occupancy == 1.0f)
{
fullyOccupied = true;
}
else
{
fullyOccupied = false;
}


}
public float Occupancy
{
get { return occupancy; }
set { occupancy = value; }

}

public int Stories
{
get { return numOfStories; }
}

public int Apts
{
get { return numofApts; }
}

public bool FullyOccupied
{
get { return fullyOccupied; }
}

}
14 replies
CC#
Created by Darma on 4/15/2023 in #help
❔ What does it mean by inaccessible
Thank you very much
11 replies
CC#
Created by Darma on 4/15/2023 in #help
❔ What does it mean by inaccessible
Ah
11 replies
CC#
Created by Darma on 4/9/2023 in #help
❔ Shuffling Table Values
9 replies
CC#
Created by Darma on 4/9/2023 in #help
❔ Shuffling Table Values
public static int[] shuffleArray(int[] array)
{
int[] shuffled = new int[array.Length];
Random rnd = new Random();

for (int i = 0; i < shuffled.Length; i++)
{
shuffled[i] = array[rnd.Next(0, shuffled.Length)];
Console.Write(shuffled[i] + ", ");
}

return shuffled;
}
public static int[] shuffleArray(int[] array)
{
int[] shuffled = new int[array.Length];
Random rnd = new Random();

for (int i = 0; i < shuffled.Length; i++)
{
shuffled[i] = array[rnd.Next(0, shuffled.Length)];
Console.Write(shuffled[i] + ", ");
}

return shuffled;
}
9 replies
CC#
Created by Darma on 4/9/2023 in #help
❔ Shuffling Table Values
public static int[] shuffleArray(int[] array)
{
int[] shuffled = new int[array.Length];

for (int i = 0; i < shuffled.Length - 1; i++)
{

}

return shuffled;
}
public static int[] shuffleArray(int[] array)
{
int[] shuffled = new int[array.Length];

for (int i = 0; i < shuffled.Length - 1; i++)
{

}

return shuffled;
}
9 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
Gotcha
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
for (int i = 0; i < array.Length; i++)
{
if (array[i] < array[i])
{
sorted = true;
Console.WriteLine("Hooray it's sorted!");
}
else
{
sorted = false;
Console.WriteLine("Not sorted yet!");
break;
}
}
for (int i = 0; i < array.Length; i++)
{
if (array[i] < array[i])
{
sorted = true;
Console.WriteLine("Hooray it's sorted!");
}
else
{
sorted = false;
Console.WriteLine("Not sorted yet!");
break;
}
}
where would the i + 1 be placed
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
I'm dealing with a 1D array so I'm wondering how I compare 2 consecutive indexes at the same time
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
Yeah I ran it and saw that as well
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
I ran the code and realized that it's just going to spam the lines I've told the console to write the moment that 2 values happen to be sorted properly as opposed to the entire table being sorted
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Random Sort Assignment
public static bool checkIfSorted(int[] array)
{
bool sorted = false;

for (int i = 0; i < array.Length; i++)
{
if (array[i] < array[i+1])
{
sorted = true;
Console.WriteLine("Hooray it's sorted!");
}
else
{
sorted = false;
Console.WriteLine("Not sorted yet!");
}
}

return sorted;
}
public static bool checkIfSorted(int[] array)
{
bool sorted = false;

for (int i = 0; i < array.Length; i++)
{
if (array[i] < array[i+1])
{
sorted = true;
Console.WriteLine("Hooray it's sorted!");
}
else
{
sorted = false;
Console.WriteLine("Not sorted yet!");
}
}

return sorted;
}
23 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Parameter Shenanigans
alright, thank you very much
41 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Parameter Shenanigans
btw what are ref and out
41 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Parameter Shenanigans
ok that makes so much sense lol
41 replies
CC#
Created by Darma on 4/8/2023 in #help
❔ Parameter Shenanigans
Man
41 replies